$needCollation = 'utf8_general_ci'; // укажите здесь нужную кодировку
$res = $DB->Query('SHOW TABLE STATUS');
while($ts = $res->fetch()) {
if ($ts['Collation'] != $needCollation) $DB->Query('ALTER TABLE `' . $ts['Name'] . '` DEFAULT CHARACTER SET utf8 COLLATE ' . $needCollation);
$r2 = $DB->Query('SHOW FULL COLUMNS FROM ' . $ts['Name'] . ' WHERE Collation IS NOT NULL');
while($col = $r2->fetch()) {
if ($col['Collation'] != $needCollation) $DB->Query('ALTER TABLE `' . $ts['Name'] . '` CHANGE `' . $col['Field'] . '` `' . $col['Field'] . '` ' . $col['Type'] . ' CHARACTER SET utf8 COLLATE ' . $needCollation . ($col['Null'] == 'NO' ? ' NOT' : '') . ' NULL');
}
} |