diff --git a/htdocs/actioncomm.class.php b/htdocs/actioncomm.class.php index 234ad0dd74f..2daf1580f3b 100644 --- a/htdocs/actioncomm.class.php +++ b/htdocs/actioncomm.class.php @@ -97,7 +97,7 @@ class ActionComm if ($this->db->query($sql) ) { - $idaction = $this->db->last_insert_id(); + $idaction = $this->db->last_insert_id(MAIN_DB_PREFIX."actioncomm"); if ($conf->webcal->enabled) { if (is_object($webcal)) diff --git a/htdocs/adherents/adherent.class.php b/htdocs/adherents/adherent.class.php index d0e590f026c..884ab83dc1e 100644 --- a/htdocs/adherents/adherent.class.php +++ b/htdocs/adherents/adherent.class.php @@ -301,7 +301,7 @@ class Adherent if ($result) { - $this->id = $this->db->last_insert_id(); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."adherent"); return $this->update(); } else diff --git a/htdocs/adherents/adherent_type.class.php b/htdocs/adherents/adherent_type.class.php index 2bb87de7703..6532efd0f3b 100644 --- a/htdocs/adherents/adherent_type.class.php +++ b/htdocs/adherents/adherent_type.class.php @@ -20,14 +20,14 @@ * */ -/*! \file htdocs/adherents/adherent_type.class.php +/** \file htdocs/adherents/adherent_type.class.php \ingroup adherent \brief Fichier de la classe gérant les types d'adhérents \author Rodolphe Quiedeville \version $Revision$ */ -/*! \class AdherentType +/** \class AdherentType \brief Classe gérant les types d'adhérents */ @@ -43,7 +43,7 @@ class AdherentType var $commentaire; /**< commentaire */ var $vote; /** droit de vote ? */ -/*! +/** \brief AdherentType \param DB handler accès base de données */ @@ -54,7 +54,7 @@ class AdherentType $this->statut = 1; } -/*! +/** \brief print_error_list */ @@ -67,7 +67,7 @@ class AdherentType } } -/*! +/** \brief fonction qui permet de créer le status de l'adhérent \param userid userid de l'adhérent */ @@ -85,13 +85,11 @@ class AdherentType if ($result) { - $this->id = $this->db->last_insert_id(); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."adherent_type"); return $this->update(); } else { - print $this->db->error(); - print "
$sql"; - } - -} -if ($action == 'del') { - /* $sql = "DELETE FROM ".MAIN_DB_PREFIX."voyage WHERE rowid = $rowid"; - *$result = $db->query($sql); - */ -} - -if ($vline) { - $viewline = $vline; -} else { - $viewline = 20; -} print_titre("Noms de domaines internet"); diff --git a/htdocs/don.class.php b/htdocs/don.class.php index 666e26b13e2..1e3db90cb1f 100644 --- a/htdocs/don.class.php +++ b/htdocs/don.class.php @@ -196,7 +196,7 @@ class Don if ($result) { - return $this->db->last_insert_id(); + return $this->db->last_insert_id(MAIN_DB_PREFIX."don"); } else { diff --git a/htdocs/expedition/expedition.class.php b/htdocs/expedition/expedition.class.php index e65614c241f..82c5090b305 100644 --- a/htdocs/expedition/expedition.class.php +++ b/htdocs/expedition/expedition.class.php @@ -78,7 +78,7 @@ class Expedition if ( $this->db->query($sql) ) { - $this->id = $this->db->last_insert_id(); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."expedition"); /* * diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php index f1a0d233cec..ac70247856e 100644 --- a/htdocs/facture.class.php +++ b/htdocs/facture.class.php @@ -52,7 +52,6 @@ class Facture var $total; var $note; var $paye; - var $db_table; var $propalid; var $projetid; var $prefixe_facture; @@ -68,7 +67,7 @@ class Facture $this->db = $DB ; $this->socidp = $soc_idp; $this->products = array(); // Tableau de lignes de factures - $this->db_table = MAIN_DB_PREFIX."facture"; + $this->amount = 0; $this->remise = 0; $this->remise_percent = 0; @@ -172,7 +171,7 @@ class Facture $tva = tva($totalht); $total = $totalht + $tva; - $sql = "INSERT INTO $this->db_table (facnumber, fk_soc, datec, amount, remise, remise_percent"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."facture (facnumber, fk_soc, datec, amount, remise, remise_percent"; $sql .= ", datef, note, fk_user_author,fk_projet"; $sql .= ", fk_cond_reglement, fk_mode_reglement, date_lim_reglement) "; @@ -182,7 +181,7 @@ class Facture $sql .= ",".$this->cond_reglement.",".$this->mode_reglement.",".$this->db->idate($datelim).")"; if ( $this->db->query($sql) ) { - $this->id = $this->db->last_insert_id(); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."facture"); $sql = "UPDATE ".MAIN_DB_PREFIX."facture SET facnumber='(PROV".$this->id.")' WHERE rowid=".$this->id; $this->db->query($sql); diff --git a/htdocs/facturefourn.class.php b/htdocs/facturefourn.class.php index 80c0baeebe0..19339eaba3c 100644 --- a/htdocs/facturefourn.class.php +++ b/htdocs/facturefourn.class.php @@ -110,7 +110,7 @@ class FactureFourn if ( $this->db->query($sql) ) { - $this->id = $this->db->last_insert_id(); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."facture_fourn"); for ($i = 0 ; $i < sizeof($this->lignes) ; $i++) { @@ -119,7 +119,7 @@ class FactureFourn $sql .= " VALUES ($this->id);"; if ($this->db->query($sql) ) { - $idligne = $this->db->last_insert_id(); + $idligne = $this->db->last_insert_id(MAIN_DB_PREFIX."facture_fourn_det"); $this->updateline($idligne, $this->lignes[$i][0], @@ -301,7 +301,7 @@ class FactureFourn $sql .= " VALUES ($this->id);"; if ($this->db->query($sql) ) { - $idligne = $this->db->last_insert_id(); + $idligne = $this->db->last_insert_id(MAIN_DB_PREFIX."facture_fourn_det"); $this->updateline($idligne, $desc, $pu, $tauxtva, $qty); } diff --git a/htdocs/fichinter/fichinter.class.php b/htdocs/fichinter/fichinter.class.php index 1761e8271a8..3db7860d7aa 100644 --- a/htdocs/fichinter/fichinter.class.php +++ b/htdocs/fichinter/fichinter.class.php @@ -85,7 +85,7 @@ class Fichinter $result=$this->db->query($sql); if ($result) { - return $this->db->last_insert_id(); + return $this->db->last_insert_id(MAIN_DB_PREFIX."fichinter"); } else { diff --git a/htdocs/fourn/facture/paiementfourn.class.php b/htdocs/fourn/facture/paiementfourn.class.php index e832fb35a2a..d0908b5ef67 100644 --- a/htdocs/fourn/facture/paiementfourn.class.php +++ b/htdocs/fourn/facture/paiementfourn.class.php @@ -71,9 +71,9 @@ class PaiementFourn $result = $this->db->query($sql); - if (isset($result)) + if ($result) { - $this->id = $this->db->last_insert_id(); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."paiementfourn"); $label = "Règlement facture $this->facnumber - $this->societe"; @@ -89,7 +89,7 @@ class PaiementFourn // Mise a jour fk_bank dans llx_paiement_fourn if ($result) { - $this->bankid = $this->db->last_insert_id(); + $this->bankid = $this->db->last_insert_id(MAIN_DB_PREFIX."bank"); $sql = "UPDATE ".MAIN_DB_PREFIX."paiementfourn SET fk_bank=$this->bankid WHERE rowid=$this->id"; $result = $this->db->query($sql); diff --git a/htdocs/fournisseur.commande.class.php b/htdocs/fournisseur.commande.class.php index d47d1cbdd8a..c6720e218c6 100644 --- a/htdocs/fournisseur.commande.class.php +++ b/htdocs/fournisseur.commande.class.php @@ -266,7 +266,7 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_methode_commande_fournisseur as cm ON cm if ( $this->db->query($sql) ) { - $this->id = $this->db->last_insert_id(); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."commande_fournisseur"); $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur SET ref='(PROV".$this->id.")' WHERE rowid=".$this->id; if ($this->db->query($sql)) diff --git a/htdocs/lib/mysql.lib.php b/htdocs/lib/mysql.lib.php index 14401ddae02..b838bf0cb68 100644 --- a/htdocs/lib/mysql.lib.php +++ b/htdocs/lib/mysql.lib.php @@ -485,11 +485,12 @@ class DoliDb } /** - \brief Obtient l'id genéré par le dernier INSERT. - \return id + \brief Récupère l'id genéré par le dernier INSERT. + \param tab Nom de la table concernée par l'insert. Ne sert pas sous MySql mais requis pour compatibilité avec Postgresql + \return int id */ - function last_insert_id() + function last_insert_id($tab) { return mysql_insert_id($this->db); } diff --git a/htdocs/lib/pgsql.lib.php b/htdocs/lib/pgsql.lib.php index 59d84c648cd..fcfe5c355d6 100644 --- a/htdocs/lib/pgsql.lib.php +++ b/htdocs/lib/pgsql.lib.php @@ -492,8 +492,9 @@ class DoliDb } /** - \brief Obtient l'id genéré par le dernier INSERT. - \return id + \brief Récupère l'id genéré par le dernier INSERT. + \param tab Nom de la table concernée par l'insert + \return int id */ function last_insert_id($tab) diff --git a/htdocs/paiement.class.php b/htdocs/paiement.class.php index 8aa9d56a020..b43416902e5 100644 --- a/htdocs/paiement.class.php +++ b/htdocs/paiement.class.php @@ -155,7 +155,7 @@ class Paiement if ( $this->db->query($sql) ) { - $this->id = $this->db->last_insert_id(); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."paiement"); foreach ($this->amounts as $key => $value) { diff --git a/htdocs/product/album/album.class.php b/htdocs/product/album/album.class.php index 7d30482339e..441748f70d5 100644 --- a/htdocs/product/album/album.class.php +++ b/htdocs/product/album/album.class.php @@ -53,7 +53,7 @@ class Album { if ($this->db->query($sql) ) { - $idosc = $this->db->last_insert_id(); + $idosc = $this->db->last_insert_id(DB_NAME_OSC.".products"); $sql = "INSERT INTO ".DB_NAME_OSC.".products_to_categories (products_id, categories_id) VALUES ($idosc, 0)"; @@ -69,7 +69,7 @@ class Album { if ($this->db->query($sql) ) { - $id = $this->db->last_insert_id(); + $id = $this->db->last_insert_id(MAIN_DB_PREFIX."album"); if ( $this->update($id, $user) ) { diff --git a/htdocs/product/categorie/categorie.class.php b/htdocs/product/categorie/categorie.class.php index cd960eeb018..49785381a2c 100644 --- a/htdocs/product/categorie/categorie.class.php +++ b/htdocs/product/categorie/categorie.class.php @@ -47,7 +47,7 @@ class Categorie { if ($this->db->query($sql) ) { - $id = $this->db->last_insert_id(); + $id = $this->db->last_insert_id(MAIN_DB_PREFIX."album"); if ( $this->update($id, $user) ) { diff --git a/htdocs/product/concert/concert.class.php b/htdocs/product/concert/concert.class.php index b27bb001bd2..8faae9d6037 100644 --- a/htdocs/product/concert/concert.class.php +++ b/htdocs/product/concert/concert.class.php @@ -45,7 +45,7 @@ class Concert { if ($this->db->query($sql) ) { - $id = $this->db->last_insert_id(); + $id = $this->db->last_insert_id(MAIN_DB_PREFIX."concert"); if ( $this->update($id, $user) ) { diff --git a/htdocs/product/concert/lieuconcert.class.php b/htdocs/product/concert/lieuconcert.class.php index 56c4ba0471b..88b43133c89 100644 --- a/htdocs/product/concert/lieuconcert.class.php +++ b/htdocs/product/concert/lieuconcert.class.php @@ -45,7 +45,7 @@ class LieuConcert { if ($this->db->query($sql) ) { - $id = $this->db->last_insert_id(); + $id = $this->db->last_insert_id(MAIN_DB_PREFIX."lieu_concert"); if ( $this->update($id, $user) ) { diff --git a/htdocs/product/groupart/groupart.class.php b/htdocs/product/groupart/groupart.class.php index e64507b29c8..6c52805aa37 100644 --- a/htdocs/product/groupart/groupart.class.php +++ b/htdocs/product/groupart/groupart.class.php @@ -46,7 +46,7 @@ class Groupart { { - $id = $this->db->last_insert_id(); + $id = $this->db->last_insert_id(MAIN_DB_PREFIX."groupart"); if ( $this->update($id, $user) ) { diff --git a/htdocs/product/promotion/promotion.class.php b/htdocs/product/promotion/promotion.class.php index f3830c1cba3..e73db55c72f 100644 --- a/htdocs/product/promotion/promotion.class.php +++ b/htdocs/product/promotion/promotion.class.php @@ -65,7 +65,7 @@ class Promotion { if ($this->db->query($sql) ) { - $id = $this->db->last_insert_id(); + $id = $this->db->last_insert_id(DB_NAME_OSC.".specials"); return $id; } diff --git a/htdocs/product/stock/entrepot.class.php b/htdocs/product/stock/entrepot.class.php index 960911bdb5d..a09b111028a 100644 --- a/htdocs/product/stock/entrepot.class.php +++ b/htdocs/product/stock/entrepot.class.php @@ -73,7 +73,7 @@ class Entrepot if ($this->db->query($sql) ) { - $id = $this->db->last_insert_id(); + $id = $this->db->last_insert_id(MAIN_DB_PREFIX."entrepot"); if ($id > 0) { $this->id = $id; diff --git a/htdocs/projet/project.class.php b/htdocs/projet/project.class.php index 85ab3ebadee..32e5b516311 100644 --- a/htdocs/projet/project.class.php +++ b/htdocs/projet/project.class.php @@ -57,7 +57,7 @@ class Project { if ($this->db->query($sql) ) { - return $this->db->last_insert_id(); + return $this->db->last_insert_id(MAIN_DB_PREFIX."projet"); } else { diff --git a/htdocs/propal.class.php b/htdocs/propal.class.php index 22d900466ad..59eb80919f8 100644 --- a/htdocs/propal.class.php +++ b/htdocs/propal.class.php @@ -246,7 +246,7 @@ class Propal if ( $this->db->query($sql) ) { - $this->id = $this->db->last_insert_id(); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."propal"); $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."propal WHERE ref='$this->ref';"; if ( $this->db->query($sql) ) diff --git a/htdocs/retourbplc.class.php b/htdocs/retourbplc.class.php index 1525d43a28a..e5fe890efd3 100644 --- a/htdocs/retourbplc.class.php +++ b/htdocs/retourbplc.class.php @@ -84,7 +84,7 @@ class Retourbplc if ($result) { - return $this->db->last_insert_id(); + return $this->db->last_insert_id(MAIN_DB_PREFIX."transaction_bplc"); } else { diff --git a/htdocs/service.class.php b/htdocs/service.class.php index db2f2597e09..42bb95ba03f 100644 --- a/htdocs/service.class.php +++ b/htdocs/service.class.php @@ -52,13 +52,14 @@ class Service { $sql = "INSERT INTO ".MAIN_DB_PREFIX."service (datec, fk_user_author) VALUES (now(), ".$user->id.")"; if ($this->db->query($sql) ) { - $id = $this->db->last_insert_id(); + $id = $this->db->last_insert_id(MAIN_DB_PREFIX."service"); if ( $this->update($id, $user) ) { return $id; } } else { print $this->db->error() . ' in ' . $sql; + return -1; } } diff --git a/htdocs/societe.class.php b/htdocs/societe.class.php index 136dfd7651b..1f6be5136d4 100644 --- a/htdocs/societe.class.php +++ b/htdocs/societe.class.php @@ -121,7 +121,7 @@ class Societe { $result=$this->db->query($sql); if ($result) { - $this->id = $this->db->last_insert_id(); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe"); $this->creation_bit = 1; diff --git a/htdocs/telephonie/lignetel.class.php b/htdocs/telephonie/lignetel.class.php index f7f82a6f345..d388cd071e0 100644 --- a/htdocs/telephonie/lignetel.class.php +++ b/htdocs/telephonie/lignetel.class.php @@ -177,7 +177,7 @@ class LigneTel { if ( $this->db->query($sql) ) { - $this->id = $this->db->last_insert_id(); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."telephonie_societe_ligne"); $this->SetRemise($user, $this->remise, 'Remise initiale'); diff --git a/htdocs/telephonie/script/facturation-calcul.php b/htdocs/telephonie/script/facturation-calcul.php index ac04a116bdb..d76acd5ca09 100644 --- a/htdocs/telephonie/script/facturation-calcul.php +++ b/htdocs/telephonie/script/facturation-calcul.php @@ -175,7 +175,7 @@ if (!$error) if (!$error) { - $sql = "INSERT INTO llx_telephonie_facture"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_facture"; $sql .= " (fk_ligne, ligne, date)"; $sql .= " VALUES (".$ligne->id.","; @@ -183,7 +183,7 @@ if (!$error) if ($db->query($sql)) { - $facid = $db->last_insert_id(); + $facid = $db->last_insert_id(MAIN_DB_PREFIX."telephonie_facture"); } else { diff --git a/htdocs/telephonie/script/simulation.php b/htdocs/telephonie/script/simulation.php index 6654f4d0ecb..c25d545568f 100644 --- a/htdocs/telephonie/script/simulation.php +++ b/htdocs/telephonie/script/simulation.php @@ -36,7 +36,7 @@ $sql .= " 'Simulation du $date')"; if ( $db->query($sql) ) { - $simid = $db->last_insert_id(); + $simid = $db->last_insert_id(MAIN_DB_PREFIX."telephonie_simul"); } print "Simulation : $simid\n"; /******************************************************************************* diff --git a/htdocs/telephonie/telephonie.contrat.class.php b/htdocs/telephonie/telephonie.contrat.class.php index 7b6013b2dda..501192a9311 100644 --- a/htdocs/telephonie/telephonie.contrat.class.php +++ b/htdocs/telephonie/telephonie.contrat.class.php @@ -60,7 +60,7 @@ class TelephonieContrat { if ( $this->db->query($sql) ) { - $this->id = $this->db->last_insert_id(); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."telephonie_contrat"); $sql = "UPDATE ".MAIN_DB_PREFIX."telephonie_contrat"; $sql .= " SET ref='".substr("00000000".$this->id,-8)."'"; diff --git a/htdocs/telephonie/telephonie.service.class.php b/htdocs/telephonie/telephonie.service.class.php index b9c3016133d..7151edba07a 100644 --- a/htdocs/telephonie/telephonie.service.class.php +++ b/htdocs/telephonie/telephonie.service.class.php @@ -83,7 +83,7 @@ class TelephonieService { if ( $this->db->query($sql) ) { - $this->id = $this->db->last_insert_id(); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."telephonie_service"); return 0; } else diff --git a/htdocs/user.class.php b/htdocs/user.class.php index d76e3f9c3f7..bb5a81c348c 100644 --- a/htdocs/user.class.php +++ b/htdocs/user.class.php @@ -523,7 +523,8 @@ class User { if ($this->db->affected_rows()) { - $this->id = $this->db->last_insert_id(); + $table = "".MAIN_DB_PREFIX."user"; + $this->id = $this->db->last_insert_id($table); $this->admin = 0; $this->update();