FIX Tool to convert into utf8

This commit is contained in:
Laurent Destailleur
2024-09-30 20:23:27 +02:00
parent 2c518be378
commit 048072d3db

View File

@@ -53,12 +53,30 @@ if ($action == 'convert') { // Convert engine into innodb
$db->query($sql);
}
if ($action == 'convertutf8') {
$sql = "ALTER TABLE ".$db->sanitize($table)." CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci";
$db->query($sql);
$sql = "ALTER TABLE ".$db->sanitize($table)." CHARACTER SET utf8 COLLATE utf8_unicode_ci"; // Set the default value on table
$resql1 = $db->query($sql);
if (!$resql1) {
setEventMessages($db->lasterror(), null, 'warnings');
} else {
$sql = "ALTER TABLE ".$db->sanitize($table)." CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci"; // Switch fields (may fails due to foreign key)
$resql2 = $db->query($sql);
if (!$resql2) {
setEventMessages($db->lasterror(), null, 'warnings');
}
}
}
if ($action == 'convertutf8mb4') {
$sql = "ALTER TABLE ".$db->sanitize($table)." CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci";
$db->query($sql);
$sql = "ALTER TABLE ".$db->sanitize($table)." CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"; // Set the default value on table
$resql1 = $db->query($sql);
if (!$resql1) {
setEventMessages($db->lasterror(), null, 'warnings');
} else {
$sql = "ALTER TABLE ".$db->sanitize($table)." CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"; // Switch fields (may fails due to foreign key)
$resql2 = $db->query($sql);
if (!$resql2) {
setEventMessages($db->lasterror(), null, 'warnings');
}
}
}
if ($action == 'convertdynamic') {
$sql = "ALTER TABLE ".$db->sanitize($table)." ROW_FORMAT=DYNAMIC;";