run 'set names' after each connection to deal with UTF8 correctly
This commit is contained in:
		| @@ -227,4 +227,20 @@ class Memcached_DataObject extends DB_DataObject | |||||||
|         $c->set($ckey, $cached, MEMCACHE_COMPRESSED, $expiry); |         $c->set($ckey, $cached, MEMCACHE_COMPRESSED, $expiry); | ||||||
|         return new ArrayWrapper($cached); |         return new ArrayWrapper($cached); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     // We overload so that 'SET NAMES "utf8"' is called for | ||||||
|  |     // each connection | ||||||
|  |  | ||||||
|  |     function _connect() | ||||||
|  |     { | ||||||
|  |         global $_DB_DATAOBJECT; | ||||||
|  |         $exists = !empty($this->_database_dsn_md5) && | ||||||
|  |           isset($_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]); | ||||||
|  |         $result = parent::_connect(); | ||||||
|  |         if (!$exists) { | ||||||
|  |             $DB = &$_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]; | ||||||
|  |             $DB->query('SET NAMES "utf8"'); | ||||||
|  |         } | ||||||
|  |         return $result; | ||||||
|  |     } | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user