Last active
December 19, 2015 23:59
-
-
Save theophani/6038376 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (function_exists('mysql_set_charset') === false) { | |
/** | |
* Sets the client character set. | |
* | |
* Note: This function requires MySQL 5.0.7 or later. | |
* | |
* @see http://www.php.net/mysql-set-charset | |
* @param string $charset A valid character set name | |
* @param resource $link_identifier The MySQL connection | |
* @return TRUE on success or FALSE on failure | |
*/ | |
function mysql_set_charset($charset, $link_identifier = null) | |
{ | |
if ($link_identifier == null) { | |
return mysql_query('SET CHARACTER SET "'.$charset.'"'); | |
} else { | |
return mysql_query('SET CHARACTER SET "'.$charset.'"', $link_identifier); | |
} | |
} | |
} | |
$url = parse_url(getenv("CLEARDB_DATABASE_URL")); | |
$hostname = $url["host"]; | |
$username = $url["user"]; | |
$password = $url["pass"]; | |
$database = substr($url["path"],1); | |
$db_connection = mysql_pconnect($hostname, $username, $password) or die(mysql_error()); | |
mysql_set_charset('utf8', $db_connection); | |
/* | |
Lines 2 through 21 and 30 are there to make mysql not be a fucking idiot about utf8. | |
Lines 23 through 28 assume you are using heroku and will have an environment variable | |
called CLEARDB_DATABASE_URL that contains your database connection details. | |
Check this out for details on setting up a database on heroku: | |
https://devcenter.heroku.com/articles/cleardb | |
Note that I also changed the names of some variables to be more general: | |
- `$database_egatetif` is now `$database` | |
- `$egatetif` is now `$db_connection` | |
*/ | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I take it you don't save the sql dump file by any chance?