private function realGetTableCollation($tableName)
{
$utf8Support = method_exists($this->db, 'hasUTFSupport') && $this->db->hasUTFSupport();
$utf8mb4Support = $utf8Support && method_exists($this->db, 'hasUTF8mb4Support') && $this->db->hasUTF8mb4Support();
$collation = $utf8mb4Support ? 'utf8mb4_unicode_ci' : ($utf8Support ? 'utf_general_ci' : 'latin1_swedish_ci');
$query = 'SHOW TABLE STATUS LIKE ' . $this->db->q($tableName);
try {
$row = $this->db->setQuery($query)->loadAssoc();
} catch (\Exception $e) {
return $collation;
}
if (empty($row)) {
return $collation;
}
if (!isset($row['Collation'])) {
return $collation;
}
if (empty($row['Collation'])) {
return $collation;
}
return $row['Collation'];
}