From 7310c2f461afa20761126543afc8d8836e4b0084 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 25 Oct 2011 01:57:46 +0200 Subject: [PATCH] Fix: Better error management --- htdocs/comm/action/class/actioncomm.class.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 96ac4bd24ac..55dcbb0b93f 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -129,10 +129,15 @@ class ActionComm extends CommonObject # Get id from code $cactioncomm=new CActionComm($this->db); $result=$cactioncomm->fetch($this->type_code); - if ($result) + if ($result > 0) { $this->type_id=$cactioncomm->id; } + else if ($result == 0) + { + $this->error='Failed to get record with code AC_OTH from dictionnary "type of events"'; + return -1; + } else { $this->error=$cactioncomm->error; @@ -148,7 +153,7 @@ class ActionComm extends CommonObject } - $this->db->begin("ActionComm::add"); + $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm"; $sql.= "(datec,"; @@ -208,13 +213,13 @@ class ActionComm extends CommonObject // Fin appel triggers } - $this->db->commit("ActionComm::add"); + $this->db->commit(); return $this->id; } else { $this->error=$this->db->lasterror().' sql='.$sql; - $this->db->rollback("ActionComm::add"); + $this->db->rollback(); return -1; }