diff options
author | Evan Prodromou <evan@controlyourself.ca> | 2009-04-26 12:13:49 -0400 |
---|---|---|
committer | Evan Prodromou <evan@controlyourself.ca> | 2009-04-26 12:14:04 -0400 |
commit | a7089de22851060c551c9f43366bc197bddebb07 (patch) | |
tree | a710f9e1296e6dae9e970c0ca1f0dbba77377a60 /classes | |
parent | 4a86823d064e13446733f86218bbe0f49dea7714 (diff) |
run 'set names' after each connection to deal with UTF8 correctly
Diffstat (limited to 'classes')
-rw-r--r-- | classes/Memcached_DataObject.php | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/classes/Memcached_DataObject.php b/classes/Memcached_DataObject.php index 5f71f716b..877bbf2e0 100644 --- a/classes/Memcached_DataObject.php +++ b/classes/Memcached_DataObject.php @@ -227,4 +227,20 @@ class Memcached_DataObject extends DB_DataObject $c->set($ckey, $cached, MEMCACHE_COMPRESSED, $expiry); 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; + } } |