19 declare(strict_types=1);
30 'STRICT_TRANS_TABLES',
35 'ERROR_FOR_DIVISION_BY_ZERO',
36 'NO_ENGINE_SUBSTITUTION',
53 $this->pdo->exec(
"SET SESSION sql_mode = '" . implode(
",", $this->modes) .
"';");
67 PDO::MYSQL_ATTR_USE_BUFFERED_QUERY =>
true,
68 PDO::ATTR_TIMEOUT => 300 * 60,
75 $this->pdo->exec(
"ALTER TABLE {$table_name} ENGINE={$engine}");
77 $this->pdo->exec(
"ALTER TABLE {$table_name}_seq ENGINE={$engine}");
79 }
catch (PDOException
$e) {
89 $engines = $this->
queryCol(
'SHOW ENGINES');
90 if (!in_array($engine, $engines,
true)) {
95 array_walk($tables,
function (
string $table_name) use (&
$errors, $engine):
void {
97 $this->pdo->exec(
"ALTER TABLE $table_name ENGINE=$engine");
99 $this->pdo->exec(
"ALTER TABLE {$table_name}_seq ENGINE=$engine");
102 $errors[$table_name] = $e->getMessage();
113 $collation_split = explode(
"_", $collation);
114 $character = $collation_split[0] ??
'utf8mb4';
115 $collate = $collation;
116 $q =
"ALTER TABLE {$this->quoteIdentifier($table_name)} CONVERT TO CHARACTER SET {$character} COLLATE {$collate};";
118 $this->pdo->exec($q);
119 }
catch (PDOException
$e) {
153 $query =
"INSERT INTO $sequence_name ($seqcol_name) VALUES (NULL)";
156 }
catch (PDOException
$e) {
160 $result = $this->
query(
'SELECT LAST_INSERT_ID() AS next');
161 $value = $result->fetchObject()->next;
163 if (is_numeric($value)) {
164 $query =
"DELETE FROM $sequence_name WHERE $seqcol_name < $value";
migrateAllTablesToCollation(string $collation=ilDBConstants::MYSQL_COLLATION_UTF8MB4)
const MYSQL_COLLATION_UTF8MB4
supportsEngineMigration()
getSequenceName(string $table_name)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
supportsCollationMigration()
loadModule(string $module)
const MYSQL_ENGINE_INNODB
migrateAllTablesToEngine(string $engine=ilDBConstants::MYSQL_ENGINE_INNODB)
nextId(string $table_name)
listTables(?string $database=null)
doesCollationSupportMB4Strings()
quoteIdentifier(string $identifier, bool $check_option=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getAdditionalAttributes()
queryCol(string $query, int $type=PDO::FETCH_ASSOC, int $colnum=0)
migrateTableCollation(string $table_name, string $collation=ilDBConstants::MYSQL_COLLATION_UTF8MB4)
migrateTableToEngine(string $table_name, string $engine=ilDBConstants::MYSQL_ENGINE_INNODB)
sequenceExists(string $sequence)