Fix: Correction pour compatibilite mysql/pgsql.

This commit is contained in:
Laurent Destailleur 2005-03-15 17:28:59 +00:00
parent 9ecc04dafa
commit 74519c6f30

View File

@ -120,7 +120,7 @@ class Product
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ( $result ) if ( $result )
{ {
$id = $this->db->last_insert_id(); $id = $this->db->last_insert_id(MAIN_DB_PREFIX."product");
if ($id > 0) if ($id > 0)
{ {
@ -206,9 +206,9 @@ class Product
* \param user utilisateur qui modifie le prix * \param user utilisateur qui modifie le prix
*/ */
function _log_price($user) function _log_price($user)
{ {
// On supprimme ligne existante au cas ou
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_price "; $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_price ";
$sql .= "WHERE date_price = now()"; $sql .= "WHERE date_price = now()";
$sql .= " and fk_product = ".$this->id; $sql .= " and fk_product = ".$this->id;
@ -216,27 +216,23 @@ class Product
$sql .= " and price = ".ereg_replace(",",".",$this->price); $sql .= " and price = ".ereg_replace(",",".",$this->price);
$sql .= " and envente = ".$this->envente; $sql .= " and envente = ".$this->envente;
$sql .= " and tva_tx = ".$this->tva_tx; $sql .= " and tva_tx = ".$this->tva_tx;
$this->db->query($sql); $this->db->query($sql);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_price "; // On ajoute nouveau tarif
$sql .= " SET date_price = now()"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_price(date_price,fk_product,fk_user_author,price,envente,tva_tx) ";
$sql .= " ,fk_product = ".$this->id; $sql .= " VALUES(now(),".$this->id.",".$user->id.",".ereg_replace(",",".",$this->price).",".$this->envente.",".$this->tva_tx;
$sql .= " ,fk_user_author = ".$user->id; $sql .= ")";
$sql .= " ,price = ".ereg_replace(",",".",$this->price); if ($this->db->query($sql) )
$sql .= " ,envente = ".$this->envente; {
$sql .= " ,tva_tx = ".$this->tva_tx; return 1;
}
if ($this->db->query($sql) ) else
{ {
return 1; dolibarr_print_error($this->db);
} return 0;
else }
{ }
dolibarr_print_error($this->db);
return 0;
}
}
/** /**
* \brief Modifie le prix d'achat pour un fournisseur * \brief Modifie le prix d'achat pour un fournisseur
@ -272,14 +268,12 @@ class Product
} }
else else
{ {
print $sql . " ". $this->db->error();
dolibarr_print_error($this->db); dolibarr_print_error($this->db);
return 2; return 2;
} }
} }
else else
{ {
print $sql . " ". $this->db->error();
dolibarr_print_error($this->db); dolibarr_print_error($this->db);
return 2; return 2;
} }