]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Use mysql_set_charset for connection instead of SET NAMES
authorEvan Prodromou <evan@controlyourself.ca>
Sat, 30 May 2009 17:59:57 +0000 (13:59 -0400)
committerEvan Prodromou <evan@controlyourself.ca>
Sat, 30 May 2009 17:59:57 +0000 (13:59 -0400)
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.

classes/Memcached_DataObject.php

index 52ad4100fcec32cc3a823172b269556fdab32a06..33ac70dd045643a5a57ff87e58d383a0bc52bd2b 100644 (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;