Fix avoid errors with postgresql

This commit is contained in:
Laurent Destailleur 2017-06-27 18:35:10 +02:00
parent d186aed96c
commit 2f9cc1c919

View File

@ -219,12 +219,22 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i',$action))
if ($success)
{
// Insert MAIN_VERSION_FIRST_INSTALL in a dedicated transaction. So if it fails (when first install was already done), we can do other following requests.
$db->begin();
dolibarr_install_syslog('step5: set MAIN_VERSION_FIRST_INSTALL const to ' . $targetversion, LOG_DEBUG);
$resql=$db->query("INSERT INTO ".MAIN_DB_PREFIX."const(name,value,type,visible,note,entity) values(".$db->encrypt('MAIN_VERSION_FIRST_INSTALL',1).",".$db->encrypt($targetversion,1).",'chaine',0,'Dolibarr version when first install',0)");
//if (! $resql) dol_print_error($db,'Error in setup program'); // We ignore errors. Key may already exists
$conf->global->MAIN_VERSION_FIRST_INSTALL=$targetversion;
if ($resql)
{
$conf->global->MAIN_VERSION_FIRST_INSTALL=$targetversion;
$db->commit();
}
else
{
//if (! $resql) dol_print_error($db,'Error in setup program'); // We ignore errors. Key may already exists
$db->commit();
}
$db->begin();
dolibarr_install_syslog('step5: set MAIN_VERSION_LAST_INSTALL const to ' . $targetversion, LOG_DEBUG);
$resql=$db->query("DELETE FROM ".MAIN_DB_PREFIX."const WHERE ".$db->decrypt('name')."='MAIN_VERSION_LAST_INSTALL'");