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 76e1e35 commit 064ccf8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions install/mysqlRestore.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,11 @@ function executeFile($filename) {
}
}

// Modificar comandos CREATE TABLE para CREATE TABLE IF NOT EXISTS, se necessário
// Modificar comandos CREATE TABLE para incluir DROP TABLE IF EXISTS antes de CREATE TABLE
foreach ($createTableCommands as &$command) {
if (stripos($command, 'CREATE TABLE') !== false && stripos($command, 'IF NOT EXISTS') === false) {
$command = str_ireplace('CREATE TABLE', 'CREATE TABLE IF NOT EXISTS', $command);
if (stripos($command, 'CREATE TABLE') !== false) {
$tableName = preg_split('/[\s`]+/', $command)[2]; // Extrair o nome da tabela
$command = 'DROP TABLE IF EXISTS `' . $tableName . '`;' . "\n" . $command;
}
}

Expand Down

0 comments on commit 064ccf8

Please sign in to comment.