Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Neto committed Jul 28, 2024
1 parent b377cba commit 5f07ea0
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions install/mysqlRestore.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ function executeFile($filename) {
}
}

// Desativar a verificação de chaves estrangeiras
try {
$global['mysqli']->query('SET foreign_key_checks = 0;');
} catch (Exception $e) {
echo 'sqlDAL::executeFile ' . $filename . ' Error performing query \'SET foreign_key_checks = 0\': ' . $e->getMessage() . PHP_EOL;
return;
}

// Executar DROP TABLE IF EXISTS separado de CREATE TABLE
foreach ($tables as $table) {
$dropTableCommand = 'DROP TABLE IF EXISTS `' . $table . '`;';
Expand Down Expand Up @@ -146,6 +154,13 @@ function executeFile($filename) {
}
}

// Reativar a verificação de chaves estrangeiras
try {
$global['mysqli']->query('SET foreign_key_checks = 1;');
} catch (Exception $e) {
echo 'sqlDAL::executeFile ' . $filename . ' Error performing query \'SET foreign_key_checks = 1\': ' . $e->getMessage() . PHP_EOL;
}

// Desbloquear as tabelas no final
try {
$global['mysqli']->query('UNLOCK TABLES;');
Expand Down

0 comments on commit 5f07ea0

Please sign in to comment.