From 01c84cbb2e9106b9204bd7975d55a24321d83b2f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 18 Mar 2005 23:56:41 +0000 Subject: [PATCH] =?UTF-8?q?Fix:=20Pour=20rendre=20la=20fonction=20last=5Fi?= =?UTF-8?q?nsert=5Fid=20compatible=20enre=20mysql=20et=20pgsql,=20on=20ren?= =?UTF-8?q?d=20le=20param=E8tre=20obligatoire.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/actioncomm.class.php | 2 +- htdocs/adherents/adherent.class.php | 2 +- htdocs/adherents/adherent_type.class.php | 18 ++++++------- htdocs/adherents/cotisation.class.php | 2 +- htdocs/bon-prelevement.class.php | 2 +- htdocs/bookmark4u.class.php | 2 +- htdocs/boutique/auteur/auteur.class.php | 2 +- htdocs/boutique/editeur/editeur.class.php | 2 +- htdocs/boutique/livre/livre.class.php | 4 +-- .../boutique/newsletter/newsletter.class.php | 2 +- .../notification/notification.class.php | 2 +- htdocs/chargesociales.class.php | 4 +-- htdocs/comm/mailing/mailing.class.php | 2 +- htdocs/commande/commande.class.php | 2 +- htdocs/compta/bank/account.class.php | 8 +++--- htdocs/compta/comptacompte.class.php | 2 +- .../compta/deplacement/deplacement.class.php | 2 +- .../modules/compta.export.poivre.class.php | 4 +-- htdocs/compta/facture/facture-rec.class.php | 2 +- htdocs/compta/voyage/bilan.php | 2 +- htdocs/compta/voyage/index.php | 2 +- htdocs/contact.class.php | 2 +- htdocs/contrat/contrat.class.php | 2 +- htdocs/domain/index.php | 26 ------------------- htdocs/don.class.php | 2 +- htdocs/expedition/expedition.class.php | 2 +- htdocs/facture.class.php | 7 +++-- htdocs/facturefourn.class.php | 6 ++--- htdocs/fichinter/fichinter.class.php | 2 +- htdocs/fourn/facture/paiementfourn.class.php | 6 ++--- htdocs/fournisseur.commande.class.php | 2 +- htdocs/lib/mysql.lib.php | 7 ++--- htdocs/lib/pgsql.lib.php | 5 ++-- htdocs/paiement.class.php | 2 +- htdocs/product/album/album.class.php | 4 +-- htdocs/product/categorie/categorie.class.php | 2 +- htdocs/product/concert/concert.class.php | 2 +- htdocs/product/concert/lieuconcert.class.php | 2 +- htdocs/product/groupart/groupart.class.php | 2 +- htdocs/product/promotion/promotion.class.php | 2 +- htdocs/product/stock/entrepot.class.php | 2 +- htdocs/projet/project.class.php | 2 +- htdocs/propal.class.php | 2 +- htdocs/retourbplc.class.php | 2 +- htdocs/service.class.php | 3 ++- htdocs/societe.class.php | 2 +- htdocs/telephonie/lignetel.class.php | 2 +- .../telephonie/script/facturation-calcul.php | 4 +-- htdocs/telephonie/script/simulation.php | 2 +- .../telephonie/telephonie.contrat.class.php | 2 +- .../telephonie/telephonie.service.class.php | 2 +- htdocs/user.class.php | 3 ++- 52 files changed, 78 insertions(+), 105 deletions(-) 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

"; return 0; } } @@ -123,7 +121,7 @@ class AdherentType } } -/*! +/** \brief fonction qui permet de supprimer le status de l'adhérent \param rowid */ @@ -151,7 +149,7 @@ class AdherentType } } - /*! + /** \brief fonction qui permet de récupérer le status de l'adhérent \param rowid */ diff --git a/htdocs/adherents/cotisation.class.php b/htdocs/adherents/cotisation.class.php index 9700686c8af..73947aa80cd 100644 --- a/htdocs/adherents/cotisation.class.php +++ b/htdocs/adherents/cotisation.class.php @@ -192,7 +192,7 @@ class Cotisation if ($result) { - return $this->db->last_insert_id(); + return $this->db->last_insert_id(MAIN_DB_PREFIX."don"); } else { diff --git a/htdocs/bon-prelevement.class.php b/htdocs/bon-prelevement.class.php index f91509ca6c7..3bf8c767a22 100644 --- a/htdocs/bon-prelevement.class.php +++ b/htdocs/bon-prelevement.class.php @@ -156,7 +156,7 @@ class BonPrelevement if ($this->db->query($sql)) { - $ligne_id = $this->db->last_insert_id(); + $ligne_id = $this->db->last_insert_id(MAIN_DB_PREFIX."prelevement_lignes"); $result = 0; } else diff --git a/htdocs/bookmark4u.class.php b/htdocs/bookmark4u.class.php index b1c87df8cca..b7b60246a66 100644 --- a/htdocs/bookmark4u.class.php +++ b/htdocs/bookmark4u.class.php @@ -132,7 +132,7 @@ class Bookmark4u { if ($this->db->affected_rows()) { - $this->uid = $this->db->last_insert_id(); + $this->uid = $this->db->last_insert_id("bookmark4u.bk4u_passwd"); $sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark4u_login"; $sql .= " (fk_user, bk4u_uid)"; diff --git a/htdocs/boutique/auteur/auteur.class.php b/htdocs/boutique/auteur/auteur.class.php index 2c9f8ed7ce4..6accc6c15ab 100644 --- a/htdocs/boutique/auteur/auteur.class.php +++ b/htdocs/boutique/auteur/auteur.class.php @@ -53,7 +53,7 @@ class Auteur { if ($this->db->query($sql) ) { - $id = $this->db->last_insert_id(); + $id = $this->db->last_insert_id(MAIN_DB_PREFIX."auteur"); if ( $this->update($id, $user) ) { diff --git a/htdocs/boutique/editeur/editeur.class.php b/htdocs/boutique/editeur/editeur.class.php index 213fcfc372b..c846ece1710 100644 --- a/htdocs/boutique/editeur/editeur.class.php +++ b/htdocs/boutique/editeur/editeur.class.php @@ -41,7 +41,7 @@ class Editeur { if ($this->db->query($sql) ) { - $id = $this->db->last_insert_id(); + $id = $this->db->last_insert_id(MAIN_DB_PREFIX."editeur"); if ( $this->update($id, $user) ) { diff --git a/htdocs/boutique/livre/livre.class.php b/htdocs/boutique/livre/livre.class.php index 1db954c693f..8218354acf5 100644 --- a/htdocs/boutique/livre/livre.class.php +++ b/htdocs/boutique/livre/livre.class.php @@ -57,7 +57,7 @@ class Livre { 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)"; @@ -73,7 +73,7 @@ class Livre { if ($this->db->query($sql) ) { - $id = $this->db->last_insert_id(); + $id = $this->db->last_insert_id(MAIN_DB_PREFIX."livre"); if ( $this->update($id, $user) ) { diff --git a/htdocs/boutique/newsletter/newsletter.class.php b/htdocs/boutique/newsletter/newsletter.class.php index 806d18c449b..702d54803a4 100644 --- a/htdocs/boutique/newsletter/newsletter.class.php +++ b/htdocs/boutique/newsletter/newsletter.class.php @@ -52,7 +52,7 @@ class Newsletter { if ($this->db->query($sql) ) { - $id = $this->db->last_insert_id(); + $id = $this->db->last_insert_id(MAIN_DB_PREFIX."newsletter"); if ( $this->update($id, $user) ) { diff --git a/htdocs/boutique/notification/notification.class.php b/htdocs/boutique/notification/notification.class.php index 8df613ce97c..d8b399c1af0 100644 --- a/htdocs/boutique/notification/notification.class.php +++ b/htdocs/boutique/notification/notification.class.php @@ -41,7 +41,7 @@ class Editeur { if ($this->db->query($sql) ) { - $id = $this->db->last_insert_id(); + $id = $this->db->last_insert_id(MAIN_DB_PREFIX."editeur"); if ( $this->update($id, $user) ) { diff --git a/htdocs/chargesociales.class.php b/htdocs/chargesociales.class.php index 6e4371f79e7..97a80c54ee8 100644 --- a/htdocs/chargesociales.class.php +++ b/htdocs/chargesociales.class.php @@ -79,13 +79,13 @@ class PaiementCharge { if ( $this->db->query($sql) ) { - $this->id = $this->db->last_insert_id(); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."paiementcharge"); } else { $sql_err++; - print "Error: $sql : ".$this->db->error(); + dolibarr_syslog("chargessociales::create Echec $sql"); } } diff --git a/htdocs/comm/mailing/mailing.class.php b/htdocs/comm/mailing/mailing.class.php index fe728926c20..537b7a39f85 100644 --- a/htdocs/comm/mailing/mailing.class.php +++ b/htdocs/comm/mailing/mailing.class.php @@ -107,7 +107,7 @@ class Mailing $result=$this->db->query($sql); if ($result) { - $this->id = $this->db->last_insert_id($result); + $this->id = $this->db->last_insert_id($this->db_table); if ($this->update() > 0) { diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php index bbf13d8732c..e57e9f13fd7 100644 --- a/htdocs/commande/commande.class.php +++ b/htdocs/commande/commande.class.php @@ -224,7 +224,7 @@ class Commande if ( $this->db->query($sql) ) { - $this->id = $this->db->last_insert_id(); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."commande"); /* * Insertion des produits dans la base diff --git a/htdocs/compta/bank/account.class.php b/htdocs/compta/bank/account.class.php index c365577b0d8..0b4c72a61bc 100644 --- a/htdocs/compta/bank/account.class.php +++ b/htdocs/compta/bank/account.class.php @@ -88,15 +88,13 @@ class Account if ($this->db->query($sql)) { - $rowid = $this->db->last_insert_id(); + $rowid = $this->db->last_insert_id(MAIN_DB_PREFIX."bank_url"); return $rowid; } else { return ''; - print $this->db->error(); - print "
$sql"; } } /* @@ -165,7 +163,7 @@ class Account if ($this->db->query($sql)) { - $rowid = $this->db->last_insert_id(); + $rowid = $this->db->last_insert_id(MAIN_DB_PREFIX."bank"); if ($categorie) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class (lineid, fk_categ) VALUES ('$rowid', '$categorie')"; @@ -214,7 +212,7 @@ class Account { if ($this->db->affected_rows()) { - $this->id = $this->db->last_insert_id(); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."bank_account"); if ( $this->update() ) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank (datec, label, amount, fk_account,datev,dateo,fk_type,rappro) "; diff --git a/htdocs/compta/comptacompte.class.php b/htdocs/compta/comptacompte.class.php index cb8e967fb39..d8b5b852d7a 100644 --- a/htdocs/compta/comptacompte.class.php +++ b/htdocs/compta/comptacompte.class.php @@ -78,7 +78,7 @@ class ComptaCompte $result = $this->db->query($sql); if ( $result ) { - $id = $this->db->last_insert_id(); + $id = $this->db->last_insert_id(MAIN_DB_PREFIX."compta_compte_generaux"); if ($id > 0) { diff --git a/htdocs/compta/deplacement/deplacement.class.php b/htdocs/compta/deplacement/deplacement.class.php index b4d29bd07e6..d5997cd91a3 100644 --- a/htdocs/compta/deplacement/deplacement.class.php +++ b/htdocs/compta/deplacement/deplacement.class.php @@ -47,7 +47,7 @@ class Deplacement $result = $this->db->query($sql); if ($result) { - $this->id = $this->db->last_insert_id(); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."deplacement"); if ( $this->update($user) ) { return $this->id; diff --git a/htdocs/compta/export/modules/compta.export.poivre.class.php b/htdocs/compta/export/modules/compta.export.poivre.class.php index 46267dacb6b..632fe8517cb 100644 --- a/htdocs/compta/export/modules/compta.export.poivre.class.php +++ b/htdocs/compta/export/modules/compta.export.poivre.class.php @@ -110,7 +110,7 @@ class ComptaExportPoivre if ($this->db->query($sql)) { - $ecid = $this->db->last_insert_id(); + $ecid = $this->db->last_insert_id(MAIN_DB_PREFIX."export_compta"); } else { @@ -124,7 +124,7 @@ class ComptaExportPoivre { dolibarr_syslog("ComptaExportPoivre::Export ref : $ref"); - $this->id = $this->db->last_insert_id(); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."export_compta"); $fxname = DOL_DATA_ROOT."/compta/export/".$ref.".xls"; diff --git a/htdocs/compta/facture/facture-rec.class.php b/htdocs/compta/facture/facture-rec.class.php index a26031ac16f..f9475562ab2 100644 --- a/htdocs/compta/facture/facture-rec.class.php +++ b/htdocs/compta/facture/facture-rec.class.php @@ -90,7 +90,7 @@ class FactureRec $sql .= " VALUES ('$this->titre', '$facsrc->socidp', now(), '$facsrc->amount', '$facsrc->remise', '$facsrc->remise_percent', '$this->note','$user->id', '$facsrc->projetid', '$facsrc->cond_reglement_id')"; if ( $this->db->query($sql) ) { - $this->id = $this->db->last_insert_id(); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."facture_rec"); /* * Produits diff --git a/htdocs/compta/voyage/bilan.php b/htdocs/compta/voyage/bilan.php index 37340742531..4be38c1f541 100644 --- a/htdocs/compta/voyage/bilan.php +++ b/htdocs/compta/voyage/bilan.php @@ -33,7 +33,7 @@ if ($action == 'add') { $result = $db->query($sql); if ($result) { - $rowid = $db->last_insert_id(); + $rowid = $db->last_insert_id(MAIN_DB_PREFIX."voyage"); } else { print $db->error(); diff --git a/htdocs/compta/voyage/index.php b/htdocs/compta/voyage/index.php index bc5c0dfce73..fa033f0c33c 100644 --- a/htdocs/compta/voyage/index.php +++ b/htdocs/compta/voyage/index.php @@ -32,7 +32,7 @@ if ($action == 'add') { $result = $db->query($sql); if ($result) { - $rowid = $db->last_insert_id(); + $rowid = $db->last_insert_id(MAIN_DB_PREFIX."voyage"); } else { print $db->error(); diff --git a/htdocs/contact.class.php b/htdocs/contact.class.php index 44de3803186..8bc25b9d6d4 100644 --- a/htdocs/contact.class.php +++ b/htdocs/contact.class.php @@ -77,7 +77,7 @@ class Contact if ($this->db->query($sql) ) { - $id = $this->db->last_insert_id(); + $id = $this->db->last_insert_id(MAIN_DB_PREFIX."socpeople"); $this->update($id, $user); diff --git a/htdocs/contrat/contrat.class.php b/htdocs/contrat/contrat.class.php index 5400f249092..5f040fe464b 100644 --- a/htdocs/contrat/contrat.class.php +++ b/htdocs/contrat/contrat.class.php @@ -213,7 +213,7 @@ class Contrat $sql .= ",".$this->db->idate($this->date_contrat) .")"; if ($this->db->query($sql)) { - $this->id = $this->db->last_insert_id(); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."contrat"); $result = 0 ; } else diff --git a/htdocs/domain/index.php b/htdocs/domain/index.php index 505ff4b6a30..0773336deba 100644 --- a/htdocs/domain/index.php +++ b/htdocs/domain/index.php @@ -24,32 +24,6 @@ require("./pre.inc.php"); llxHeader(); -if ($action == 'add') { - - $sql = "INSERT INTO ".MAIN_DB_PREFIX."voyage (date_depart, date_arrivee, amount, depart, arrivee, fk_reduc, reduction) "; - $sql .= " VALUES ('$date_depart','$date_arrivee',$amount,'$depart','$arrivee',$reducid, $reduc);"; - - $result = $db->query($sql); - if ($result) { - $rowid = $db->last_insert_id(); - - } else { - print $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();