Fix: pgsql compatibility

This commit is contained in:
Regis Houssin
2010-04-16 09:50:33 +00:00
parent 138b3dfef2
commit faef96823f
9 changed files with 20 additions and 18 deletions

View File

@@ -99,7 +99,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes
// D'abord on recupere la valeur max (reponse immediate car champ indexe) // D'abord on recupere la valeur max (reponse immediate car champ indexe)
$posindice=8; $posindice=8;
$sql = "SELECT MAX(0+SUBSTRING(ref,".$posindice.")) as max"; $sql = "SELECT MAX(SUBSTRING(ref,".$posindice.")) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."commande"; $sql.= " FROM ".MAIN_DB_PREFIX."commande";
$sql.= " WHERE ref like '".$this->prefix."%'"; $sql.= " WHERE ref like '".$this->prefix."%'";
$sql.= " AND entity = ".$conf->entity; $sql.= " AND entity = ".$conf->entity;
@@ -108,7 +108,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes
if ($resql) if ($resql)
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if ($obj) $max = $obj->max; if ($obj) $max = intval($obj->max);
else $max=0; else $max=0;
} }
else else

View File

@@ -124,7 +124,7 @@ class mod_facture_terre extends ModeleNumRefFactures
// D'abord on recupere la valeur max (reponse immediate car champ ind<6E>x<EFBFBD>) // D'abord on recupere la valeur max (reponse immediate car champ ind<6E>x<EFBFBD>)
$posindice=8; $posindice=8;
$sql = "SELECT MAX(0+SUBSTRING(facnumber,".$posindice.")) as max"; $sql = "SELECT MAX(SUBSTRING(facnumber,".$posindice.")) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber like '".$prefix."%'"; $sql.= " WHERE facnumber like '".$prefix."%'";
$sql.= " AND entity = ".$conf->entity; $sql.= " AND entity = ".$conf->entity;
@@ -134,7 +134,7 @@ class mod_facture_terre extends ModeleNumRefFactures
if ($resql) if ($resql)
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if ($obj) $max = $obj->max; if ($obj) $max = intval($obj->max);
else $max=0; else $max=0;
} }
else else

View File

@@ -111,7 +111,7 @@ class mod_pacific extends ModeleNumRefFicheinter
// D'abord on recupere la valeur max (reponse immediate car champ indexe) // D'abord on recupere la valeur max (reponse immediate car champ indexe)
$posindice=8; $posindice=8;
$sql = "SELECT MAX(0+SUBSTRING(ref,".$posindice.")) as max"; $sql = "SELECT MAX(SUBSTRING(ref,".$posindice.")) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."fichinter"; $sql.= " FROM ".MAIN_DB_PREFIX."fichinter";
$sql.= " WHERE ref like '".$this->prefix."%'"; $sql.= " WHERE ref like '".$this->prefix."%'";
$sql.= " AND entity = ".$conf->entity; $sql.= " AND entity = ".$conf->entity;
@@ -120,7 +120,7 @@ class mod_pacific extends ModeleNumRefFicheinter
if ($resql) if ($resql)
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if ($obj) $max = $obj->max; if ($obj) $max = intval($obj->max);
else $max=0; else $max=0;
} }

View File

@@ -90,7 +90,7 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder
// Recherche rapide car restreint par un like sur champ indexe // Recherche rapide car restreint par un like sur champ indexe
$posindice=5; $posindice=5;
$sql = "SELECT MAX(0+SUBSTRING(ref,$posindice))"; $sql = "SELECT MAX(SUBSTRING(ref,$posindice)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."livraison"; $sql.= " FROM ".MAIN_DB_PREFIX."livraison";
$sql.= " WHERE ref like '".$blyy."%'"; $sql.= " WHERE ref like '".$blyy."%'";
$sql.= " AND entity = ".$conf->entity; $sql.= " AND entity = ".$conf->entity;
@@ -98,8 +98,9 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
$row = $db->fetch_row($resql); $obj = $db->fetch_object($resql);
$max = $row[0]; if ($obj) $max = intval($obj->max);
else $max=0;
} }
} }
else else

View File

@@ -72,7 +72,7 @@ class mod_project_simple extends ModeleNumRefProjects
// D'abord on recupere la valeur max (reponse immediate car champ indexe) // D'abord on recupere la valeur max (reponse immediate car champ indexe)
$posindice=8; $posindice=8;
$sql = "SELECT MAX(0+SUBSTRING(ref,".$posindice.")) as max"; $sql = "SELECT MAX(SUBSTRING(ref,".$posindice.")) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."projet"; $sql.= " FROM ".MAIN_DB_PREFIX."projet";
$sql.= " WHERE ref like '".$this->prefix."%'"; $sql.= " WHERE ref like '".$this->prefix."%'";
$sql.= " AND entity = ".$conf->entity; $sql.= " AND entity = ".$conf->entity;
@@ -81,7 +81,7 @@ class mod_project_simple extends ModeleNumRefProjects
if ($resql) if ($resql)
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if ($obj) $max = $obj->max; if ($obj) $max = intval($obj->max);
else $max=0; else $max=0;
} }
else else

View File

@@ -100,7 +100,7 @@ class mod_propale_marbre extends ModeleNumRefPropales
// D'abord on recupere la valeur max (reponse immediate car champ indexe) // D'abord on recupere la valeur max (reponse immediate car champ indexe)
$posindice=8; $posindice=8;
$sql = "SELECT MAX(0+SUBSTRING(ref,".$posindice.")) as max"; $sql = "SELECT MAX(SUBSTRING(ref,".$posindice.")) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."propal"; $sql.= " FROM ".MAIN_DB_PREFIX."propal";
$sql.= " WHERE ref like '".$this->prefix."%'"; $sql.= " WHERE ref like '".$this->prefix."%'";
$sql.= " AND entity = ".$conf->entity; $sql.= " AND entity = ".$conf->entity;
@@ -109,7 +109,7 @@ class mod_propale_marbre extends ModeleNumRefPropales
if ($resql) if ($resql)
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if ($obj) $max = $obj->max; if ($obj) $max = intval($obj->max);
else $max=0; else $max=0;
} }
else else

View File

@@ -105,9 +105,9 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode
if ($type == 0) $prefix=$this->prefixcustomer; if ($type == 0) $prefix=$this->prefixcustomer;
if ($type == 1) $prefix=$this->prefixsupplier; if ($type == 1) $prefix=$this->prefixsupplier;
// D'abord on r<EFBFBD>cup<EFBFBD>re la valeur max (r<EFBFBD>ponse imm<EFBFBD>diate car champ ind<EFBFBD>x<EFBFBD>) // D'abord on recupere la valeur max (reponse immediate car champ indexe)
$posindice=8; $posindice=8;
$sql = "SELECT MAX(0+SUBSTRING(".$field.",".$posindice.")) as max"; $sql = "SELECT MAX(SUBSTRING(".$field.",".$posindice.")) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."societe"; $sql.= " FROM ".MAIN_DB_PREFIX."societe";
$sql.= " WHERE ".$field." LIKE '".$prefix."%'"; $sql.= " WHERE ".$field." LIKE '".$prefix."%'";
@@ -115,7 +115,7 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode
if ($resql) if ($resql)
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if ($obj) $max = $obj->max; if ($obj) $max = intval($obj->max);
else $max=0; else $max=0;
} }
else else

View File

@@ -98,7 +98,7 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders
// D'abord on recupere la valeur max (reponse immediate car champ indexe) // D'abord on recupere la valeur max (reponse immediate car champ indexe)
$posindice=8; $posindice=8;
$sql = "SELECT MAX(0+SUBSTRING(ref,".$posindice.")) as max"; $sql = "SELECT MAX(SUBSTRING(ref,".$posindice.")) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur"; $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur";
$sql.= " WHERE ref like '".$this->prefix."%'"; $sql.= " WHERE ref like '".$this->prefix."%'";
$sql.= " AND entity = ".$conf->entity; $sql.= " AND entity = ".$conf->entity;
@@ -107,7 +107,7 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders
if ($resql) if ($resql)
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if ($obj) $max = $obj->max; if ($obj) $max = intval($obj->max);
else $max=0; else $max=0;
} }

View File

@@ -479,6 +479,7 @@ class DoliDb
} }
$ret = @pg_query($this->db, $query); $ret = @pg_query($this->db, $query);
//print $query;
if (! preg_match("/^COMMIT/i",$query) && ! preg_match("/^ROLLBACK/i",$query)) if (! preg_match("/^COMMIT/i",$query) && ! preg_match("/^ROLLBACK/i",$query))
{ {
// Si requete utilisateur, on la sauvegarde ainsi que son resultset // Si requete utilisateur, on la sauvegarde ainsi que son resultset