Fix: Migration error
This commit is contained in:
parent
0dffe08c07
commit
c56e3b5c90
@ -179,6 +179,10 @@ if (! GETPOST("action") || preg_match('/upgrade/i',GETPOST('action')))
|
|||||||
* Delete duplicates in table categorie_association
|
* Delete duplicates in table categorie_association
|
||||||
*/
|
*/
|
||||||
if ($ok)
|
if ($ok)
|
||||||
|
{
|
||||||
|
$result = $db->DDLDescTable(MAIN_DB_PREFIX."categorie_association");
|
||||||
|
$obj = $db->fetch_object($result);
|
||||||
|
if ($obj) // It table categorie_association exists
|
||||||
{
|
{
|
||||||
$couples=array();
|
$couples=array();
|
||||||
$filles=array();
|
$filles=array();
|
||||||
@ -210,11 +214,13 @@ if (! GETPOST("action") || preg_match('/upgrade/i',GETPOST('action')))
|
|||||||
|
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
|
// We delete all
|
||||||
$sql="DELETE FROM ".MAIN_DB_PREFIX."categorie_association";
|
$sql="DELETE FROM ".MAIN_DB_PREFIX."categorie_association";
|
||||||
dolibarr_install_syslog("upgrade: delete association sql=".$sql);
|
dolibarr_install_syslog("upgrade: delete association sql=".$sql);
|
||||||
$resqld=$db->query($sql);
|
$resqld=$db->query($sql);
|
||||||
if ($resqld)
|
if ($resqld)
|
||||||
{
|
{
|
||||||
|
// And we insert only each record once
|
||||||
foreach($couples as $key => $val)
|
foreach($couples as $key => $val)
|
||||||
{
|
{
|
||||||
$sql ="INSERT INTO ".MAIN_DB_PREFIX."categorie_association(fk_categorie_mere,fk_categorie_fille)";
|
$sql ="INSERT INTO ".MAIN_DB_PREFIX."categorie_association(fk_categorie_mere,fk_categorie_fille)";
|
||||||
@ -241,7 +247,8 @@ if (! GETPOST("action") || preg_match('/upgrade/i',GETPOST('action')))
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print '<div class="error">'.$langs->trans("Error").'</div>';
|
print '<div class="error">'.$langs->trans("Error").' '.$db->lasterror().'</div>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user