Merge pull request #429 from mkhon/database-charset-skip-views

Skip views when altering table charsets
This commit is contained in:
Michael Kaufmann
2017-04-15 11:28:27 +02:00
committed by GitHub

View File

@@ -85,12 +85,11 @@ class IntegrityCheck {
// fix database
Database::query('ALTER DATABASE `' . Database::getDbName() . '` CHARACTER SET utf8 COLLATE utf8_general_ci');
// fix all tables
$handle = Database::query('SHOW TABLES');
while ($row = $handle->fetch(PDO::FETCH_ASSOC)) {
foreach ($row as $table) {
$handle = Database::query('SHOW FULL TABLES WHERE Table_type != "VIEW"');
while ($row = $handle->fetch(PDO::FETCH_BOTH)) {
$table = $row[0];
Database::query('ALTER TABLE `' . $table . '` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;');
}
}
$this->_log->logAction(ADM_ACTION, LOG_WARNING, "database charset was different from UTF-8, integrity-check fixed that");
} else {
return false;