Make sure we have a DB connection before setting its charset

This commit is contained in:
Zach Copley 2009-06-18 19:19:19 +00:00
parent bde571728d
commit e0fb15c185

View File

@ -242,13 +242,16 @@ class Memcached_DataObject extends DB_DataObject
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);
if (!empty($conn)) {
if ($DB instanceof DB_mysqli) {
mysqli_set_charset($conn, 'utf8');
} else if ($DB instanceof DB_mysql) {
mysql_set_charset('utf8', $conn);
}
}
}
}
return $result;
}
}