Skip to content

Commit

Permalink
FIX Tool to convert into utf8
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Sep 30, 2024
1 parent 2c518be commit 048072d
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions htdocs/admin/system/database-tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,30 @@
$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;";
Expand Down

0 comments on commit 048072d

Please sign in to comment.