Merge pull request #9130 from hregis/8.0_bug
FIX disable/enable foreign key checking for avoid errors
This commit is contained in:
commit
a65c4ebecd
@ -1079,15 +1079,28 @@ if ($ok && GETPOST('force_utf8_on_tables','alpha'))
|
|||||||
|
|
||||||
if ($db->type == "mysql" || $db->type == "mysqli")
|
if ($db->type == "mysql" || $db->type == "mysqli")
|
||||||
{
|
{
|
||||||
|
$force_utf8_on_tables = GETPOST('force_utf8_on_tables','alpha');
|
||||||
|
|
||||||
$listoftables = $db->DDLListTables($db->database_name);
|
$listoftables = $db->DDLListTables($db->database_name);
|
||||||
|
|
||||||
|
// Disable foreign key checking for avoid errors
|
||||||
|
if ($force_utf8_on_tables == 'confirmed')
|
||||||
|
{
|
||||||
|
$sql='SET FOREIGN_KEY_CHECKS=0';
|
||||||
|
print '<!-- '.$sql.' -->';
|
||||||
|
$resql = $db->query($sql);
|
||||||
|
}
|
||||||
|
|
||||||
foreach($listoftables as $table)
|
foreach($listoftables as $table)
|
||||||
{
|
{
|
||||||
|
// do not convert llx_const if mysql encrypt/decrypt is used
|
||||||
|
if ($conf->db->dolibarr_main_db_encryption != 0 && preg_match('/\_const$/', $table)) continue;
|
||||||
|
|
||||||
print '<tr><td colspan="2">';
|
print '<tr><td colspan="2">';
|
||||||
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').')';
|
||||||
@ -1095,6 +1108,14 @@ if ($ok && GETPOST('force_utf8_on_tables','alpha'))
|
|||||||
else print ' - Disabled';
|
else print ' - Disabled';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enable foreign key checking
|
||||||
|
if ($force_utf8_on_tables == 'confirmed')
|
||||||
|
{
|
||||||
|
$sql='SET FOREIGN_KEY_CHECKS=1';
|
||||||
|
print '<!-- '.$sql.' -->';
|
||||||
|
$resql = $db->query($sql);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user