From: Evan Prodromou Date: Sat, 30 May 2009 17:59:57 +0000 (-0400) Subject: Use mysql_set_charset for connection instead of SET NAMES X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=9e16b7d89b101d8dfebdb8bf22ea56e9b8731bdd;p=quix0rs-gnu-social.git 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. --- diff --git a/classes/Memcached_DataObject.php b/classes/Memcached_DataObject.php index 52ad4100fc..33ac70dd04 100644 --- a/classes/Memcached_DataObject.php +++ b/classes/Memcached_DataObject.php @@ -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;