FIX check if "confirmed" mode

This commit is contained in:
Regis Houssin 2018-07-20 18:39:18 +02:00
parent e9d9954380
commit 719db2574e

View File

@ -1079,11 +1079,16 @@ if ($ok && GETPOST('force_utf8_on_tables','alpha'))
if ($db->type == "mysql" || $db->type == "mysqli") if ($db->type == "mysql" || $db->type == "mysqli")
{ {
$listoftables = $db->DDLListTables($db->database_name); $force_utf8_on_tables = GETPOST('force_utf8_on_tables','alpha');
$listoftables = $db->DDLListTables($db->database_name);
// Disable foreign key checking for avoid errors // Disable foreign key checking for avoid errors
$sql='SET FOREIGN_KEY_CHECKS=0'; if ($force_utf8_on_tables == 'confirmed')
$resql = $db->query($sql); {
$sql='SET FOREIGN_KEY_CHECKS=0';
$resql = $db->query($sql);
}
foreach($listoftables as $table) foreach($listoftables as $table)
{ {
@ -1094,7 +1099,7 @@ if ($ok && GETPOST('force_utf8_on_tables','alpha'))
print $table; print $table;
$sql='ALTER TABLE '.$table.' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci'; $sql='ALTER TABLE '.$table.' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci';
print '<!-- '.$sql.' -->'; print '<!-- '.$sql.' -->';
if (GETPOST('force_utf8_on_tables','alpha') == 'confirmed') if ($force_utf8_on_tables == 'confirmed')
{ {
$resql = $db->query($sql); $resql = $db->query($sql);
print ' - Done ('.($resql?'OK':'KO').')'; print ' - Done ('.($resql?'OK':'KO').')';
@ -1104,8 +1109,11 @@ if ($ok && GETPOST('force_utf8_on_tables','alpha'))
} }
// Enable foreign key checking // Enable foreign key checking
$sql='SET FOREIGN_KEY_CHECKS=1'; if ($force_utf8_on_tables == 'confirmed')
$resql = $db->query($sql); {
$sql='SET FOREIGN_KEY_CHECKS=1';
$resql = $db->query($sql);
}
} }
else else
{ {