public function getDbCollation($db)
{
if ($this->isSystemSchema($db)) {
// We don't have to check the collation of the virtual
// information_schema database: We know it!
return 'utf8_general_ci';
}
if (!$GLOBALS['cfg']['Server']['DisableIS']) {
// this is slow with thousands of databases
$sql = 'SELECT DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA' . ' WHERE SCHEMA_NAME = \'' . $this->escapeString($db) . '\' LIMIT 1';
return $this->fetchValue($sql);
} else {
$this->selectDb($db);
$return = $this->fetchValue('SELECT @@collation_database');
if ($db !== $GLOBALS['db']) {
$this->selectDb($GLOBALS['db']);
}
return $return;
}
}