Qual: Modification des commandes BEGIN, COMMIT et ROLLBACK par l'équivalent de la couche d'abstraction de base $db->begin(), $db->commit() et $db->rollback

This commit is contained in:
Laurent Destailleur 2005-01-23 18:54:46 +00:00
parent add221b92e
commit 2e3bfbe97c
5 changed files with 41 additions and 39 deletions

View File

@ -120,7 +120,7 @@ class BonPrelevement
{ {
$error == 0; $error == 0;
if ($this->db->query("BEGIN")) if ($this->db->begin())
{ {
@ -179,12 +179,12 @@ class BonPrelevement
*/ */
if ($error == 0) if ($error == 0)
{ {
$this->db->query("COMMIT"); $this->db->commit();
return 0; return 0;
} }
else else
{ {
$this->db->query("ROLLBACK"); $this->db->rollback();
dolibarr_syslog("bon-prelevment::set_credite ROLLBACK "); dolibarr_syslog("bon-prelevment::set_credite ROLLBACK ");
return -1; return -1;
} }
@ -206,7 +206,7 @@ class BonPrelevement
{ {
$error == 0; $error == 0;
if ($this->db->query("BEGIN")) if ($this->db->begin())
{ {
@ -229,12 +229,12 @@ class BonPrelevement
*/ */
if ($error == 0) if ($error == 0)
{ {
$this->db->query("COMMIT"); $this->db->commit();
return 0; return 0;
} }
else else
{ {
$this->db->query("ROLLBACK"); $this->db->rollback();
dolibarr_syslog("bon-prelevment::set_infotrans ROLLBACK "); dolibarr_syslog("bon-prelevment::set_infotrans ROLLBACK ");
return -1; return -1;
} }
@ -254,7 +254,7 @@ class BonPrelevement
{ {
$error == 0; $error == 0;
if ($this->db->query("BEGIN")) if ($this->db->begin())
{ {
@ -278,12 +278,12 @@ class BonPrelevement
*/ */
if ($error == 0) if ($error == 0)
{ {
$this->db->query("COMMIT"); $this->db->commit();
return 0; return 0;
} }
else else
{ {
$this->db->query("ROLLBACK"); $this->db->rollback();
dolibarr_syslog("bon-prelevment::set_infotrans ROLLBACK "); dolibarr_syslog("bon-prelevment::set_infotrans ROLLBACK ");
return -1; return -1;
} }

View File

@ -44,10 +44,13 @@ class PaiementCharge {
function PaiementCharge($DB) { function PaiementCharge($DB) {
$this->db = $DB; $this->db = $DB;
return 1; return 1;
} }
/**
* \brief Creation d'un paiement de charge sociale
*
*/
function create($user) { function create($user) {
$sql_err = 0; $sql_err = 0;
/* /*
@ -101,10 +104,10 @@ class PaiementCharge {
} }
} }
/* /**
* Mise a jour du lien entre le paiement de charge et la ligne dans llx_bank générée * \brief Mise a jour du lien entre le paiement de charge et la ligne dans llx_bank générée
* *
*/ */
function update_fk_bank($id_bank) { function update_fk_bank($id_bank) {
$sql = "UPDATE llx_paiementcharge set fk_bank = ".$id_bank." where rowid = ".$this->id; $sql = "UPDATE llx_paiementcharge set fk_bank = ".$id_bank." where rowid = ".$this->id;
$result = $this->db->query($sql); $result = $this->db->query($sql);
@ -144,10 +147,10 @@ class ChargeSociales {
return 1; return 1;
} }
/* /**
* Retrouve et charge une charge sociale * \brief Retrouve et charge une charge sociale
* Retour: 1 si trouve, 0 sinon * \return int 1 si trouve, 0 sinon
*/ */
function fetch($id) { function fetch($id) {
$sql = "SELECT cs.rowid,".$this->db->pdate("cs.date_ech")." as date_ech,".$this->db->pdate("cs.date_pai")." as date_pai"; $sql = "SELECT cs.rowid,".$this->db->pdate("cs.date_ech")." as date_ech,".$this->db->pdate("cs.date_pai")." as date_pai";
$sql .=", cs.libelle as lib, cs.fk_type, cs.amount, cs.paye, ".$this->db->pdate("cs.periode")." as periode, c.libelle"; $sql .=", cs.libelle as lib, cs.fk_type, cs.amount, cs.paye, ".$this->db->pdate("cs.periode")." as periode, c.libelle";
@ -214,8 +217,8 @@ class ChargeSociales {
} }
/** /**
* Tag la charge comme payée complètement * \brief Tag la charge comme payée complètement
* * \param rowid id de la ligne a modifier
*/ */
function set_payed($rowid) function set_payed($rowid)
{ {
@ -225,16 +228,15 @@ class ChargeSociales {
/** /**
* Renvoi le staut sous forme de libellé d'une charge * \brief Renvoi le staut de la charge sous forme de libellé
* * \return string libellé du statut
*/ */
function getLibStatut() { function getLibStatut() {
if ($this->paye == 0) { return "Non Payé"; } global $langs;
else { return "Payé"; }
if ($this->paye == 0) { return $langs->trans("Unpayed"); }
else { return $langs->trans("Payed"); }
} }
} }
/*
* $Id$
* $Source$
*/
?> ?>

View File

@ -82,7 +82,7 @@ class ComptaExportPoivre
$this->Agregate($linec); $this->Agregate($linec);
$this->db->query("BEGIN"); $this->db->begin();
$dt = strftime('EC%y%m', time()); $dt = strftime('EC%y%m', time());
@ -303,12 +303,12 @@ class ComptaExportPoivre
if (!$error) if (!$error)
{ {
$this->db->query("COMMIT"); $this->db->commit();
dolibarr_syslog("ComptaExportPoivre::Export COMMIT"); dolibarr_syslog("ComptaExportPoivre::Export COMMIT");
} }
else else
{ {
$this->db->query("ROLLBACK"); $this->db->rollback();
dolibarr_syslog("ComptaExportPoivre::Export ROLLBACK"); dolibarr_syslog("ComptaExportPoivre::Export ROLLBACK");
} }

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -20,7 +20,7 @@
* *
*/ */
/*! /**
\file htdocs/compta/sociales/charges.php \file htdocs/compta/sociales/charges.php
\ingroup compta \ingroup compta
\brief Fiche d'une charge sociale \brief Fiche d'une charge sociale
@ -183,7 +183,7 @@ if ($chid > 0)
// Supprimer // Supprimer
if ($cha->paye == 0 && $totalpaye <=0 && $user->rights->compta->charges) if ($cha->paye == 0 && $totalpaye <=0 && $user->rights->compta->charges)
{ {
print "<a class=\"tabAction\" href=\"charges.php?id=$cha->id&amp;action=delete\">".$langs->trans("Delete")."</a>"; print "<a class=\"butDelete\" href=\"charges.php?id=$cha->id&amp;action=delete\">".$langs->trans("Delete")."</a>";
} }
// Emettre paiement // Emettre paiement

View File

@ -447,8 +447,8 @@ class Societe {
} }
/** /**
* \brief Suppression d'une societe de la base * \brief Suppression d'une societe de la base avec ses dépendances (contacts, rib...)
* \todo Cette fonction n'est pas utilisée. Attente des contraintes d'intégrité dans MySql * \param id id de la societe à supprimer
*/ */
function delete($id) function delete($id)
@ -456,7 +456,7 @@ class Societe {
dolibarr_syslog("Societe::Delete"); dolibarr_syslog("Societe::Delete");
$sqr = 0; $sqr = 0;
if ( $this->db->query("BEGIN") ) if ( $this->db->begin())
{ {
$sql = "DELETE from ".MAIN_DB_PREFIX."socpeople "; $sql = "DELETE from ".MAIN_DB_PREFIX."socpeople ";
$sql .= " WHERE fk_soc = " . $id .";"; $sql .= " WHERE fk_soc = " . $id .";";
@ -500,7 +500,7 @@ class Societe {
if ($sqr == 3) if ($sqr == 3)
{ {
$this->db->query("COMMIT"); $this->db->commit();
// Suppression du répertoire document // Suppression du répertoire document
$docdir = $conf->societe->dir_output . "/" . $id; $docdir = $conf->societe->dir_output . "/" . $id;
@ -514,7 +514,7 @@ class Societe {
} }
else else
{ {
$this->db->query("ROLLBACK"); $this->db->rollback();
return -1; return -1;
} }
} }