Use mysql_set_charset for connection instead of SET NAMES

PHP doesn't get the info about the charset of the connection if
you use SET NAMES. So, we use the appropriate PHP function instead.
This commit is contained in:
Evan Prodromou 2009-05-30 13:59:57 -04:00
parent a262f83210
commit 9e16b7d89b
1 changed files with 8 additions and 2 deletions

View File

@ -239,8 +239,14 @@ class Memcached_DataObject extends DB_DataObject
$result = parent::_connect();
if (!$exists) {
$DB = &$_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5];
if (common_config('db', 'utf8')) {
$DB->query('SET NAMES "utf8"');
if (common_config('db', 'type') == 'mysql' &&
common_config('db', 'utf8')) {
$conn = $DB->connection;
if ($DB instanceof DB_mysqli) {
mysqli_set_charset($conn, 'utf8');
} else if ($DB instanceof DB_mysql) {
mysql_set_charset('utf8', $conn);
}
}
}
return $result;