Set the character set before making a connection

Ideally the character set should be set with the connection, and so this is
exactly what's being done now.

And now the character set code is attempted to be generalised.
This commit is contained in:
Alexei Sorokin
2020-09-16 19:34:49 +03:00
parent c2508f8fa2
commit aed2344bd4
9 changed files with 118 additions and 54 deletions

View File

@@ -863,9 +863,6 @@ class Memcached_DataObject extends Safe_DataObject
return $string;
}
// We overload so that 'SET NAMES "utf8mb4"' is called for
// each connection
public function _connect()
{
global $_DB_DATAOBJECT, $_PEAR;
@@ -908,13 +905,10 @@ class Memcached_DataObject extends Safe_DataObject
if ($result && !$exists) {
// Required to make timestamp values usefully comparable.
// And set the character set to UTF-8.
if (common_config('db', 'type') !== 'mysql') {
parent::_query("SET TIME ZONE INTERVAL '+00:00' HOUR TO MINUTE");
parent::_query("SET NAMES 'UTF8'");
} else {
parent::_query("SET time_zone = '+0:00'");
parent::_query("SET NAMES 'utf8mb4'");
}
}