mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-11-30 04:33:41 +08:00
Fixed quoting db/table names in encoding migration.
Also fixed incorrect if statement in db config.
This commit is contained in:
parent
005f0eb4fc
commit
f101e4f010
|
@ -19,7 +19,7 @@ if (env('REDIS_SERVERS', false)) {
|
|||
$mysql_host = env('DB_HOST', 'localhost');
|
||||
$mysql_host_exploded = explode(':', $mysql_host);
|
||||
$mysql_port = env('DB_PORT', 3306);
|
||||
if (count($mysql_host_exploded) > 0) {
|
||||
if (count($mysql_host_exploded) > 1) {
|
||||
$mysql_host = $mysql_host_exploded[0];
|
||||
$mysql_port = intval($mysql_host_exploded[1]);
|
||||
}
|
||||
|
|
|
@ -17,11 +17,11 @@ class UpdateDbEncodingToUt8mb4 extends Migration
|
|||
$tables = DB::select('SHOW TABLES');
|
||||
$pdo = DB::getPdo();
|
||||
$pdo->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
|
||||
$pdo->exec('ALTER DATABASE '.$database.' CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci');
|
||||
$pdo->exec('ALTER DATABASE `'.$database.'` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci');
|
||||
$key = 'Tables_in_' . $database;
|
||||
foreach ($tables as $table) {
|
||||
$tableName = $table->$key;
|
||||
$pdo->exec('ALTER TABLE '.$tableName.' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci');
|
||||
$pdo->exec('ALTER TABLE `'.$tableName.'` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,11 +36,11 @@ class UpdateDbEncodingToUt8mb4 extends Migration
|
|||
$tables = DB::select('SHOW TABLES');
|
||||
$pdo = DB::getPdo();
|
||||
$pdo->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
|
||||
$pdo->exec('ALTER DATABASE '.$database.' CHARACTER SET utf8 COLLATE utf8_unicode_ci');
|
||||
$pdo->exec('ALTER DATABASE `'.$database.'` CHARACTER SET utf8 COLLATE utf8_unicode_ci');
|
||||
$key = 'Tables_in_' . $database;
|
||||
foreach ($tables as $table) {
|
||||
$tableName = $table->$key;
|
||||
$pdo->exec('ALTER TABLE '.$tableName.' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci');
|
||||
$pdo->exec('ALTER TABLE `'.$tableName.'` CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user