-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert database structure to InnoDB with utf8mb4
- Loading branch information
1 parent
a338bf4
commit a07df02
Showing
8 changed files
with
54 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
$ret = $GLOBALS['db']->Execute("ALTER DATABASE `".DB_NAME."` CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci"); | ||
if (!$ret) | ||
return false; | ||
|
||
$tables = $GLOBALS['db']->GetAll('SHOW TABLES'); | ||
|
||
foreach ($tables as $table) { | ||
$name = $table['Tables_in_'.DB_NAME]; | ||
|
||
$ret = $GLOBALS['db']->Execute("ALTER TABLE `$name` ENGINE=InnoDB"); | ||
if (!$ret) | ||
return false; | ||
|
||
$ret = $GLOBALS['db']->Execute("ALTER TABLE `$name` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"); | ||
if (!$ret) | ||
return false; | ||
|
||
$ret = $GLOBALS['db']->Execute("REPAIR TABLE `$name`"); | ||
if (!$ret) | ||
return false; | ||
|
||
$ret = $GLOBALS['db']->Execute("OPTIMIZE TABLE `$name`"); | ||
if (!$ret) | ||
return false; | ||
} | ||
|
||
return true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters