From f138c9cf282ef1dfa0d70df14bf76820e4b49eff Mon Sep 17 00:00:00 2001 From: sparkyx Date: Tue, 18 Dec 2007 21:11:52 +0000 Subject: [PATCH] module budget : fiche --- include/class_bud_card.php | 47 +++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/include/class_bud_card.php b/include/class_bud_card.php index df4739e00..43eccdbf9 100644 --- a/include/class_bud_card.php +++ b/include/class_bud_card.php @@ -57,10 +57,16 @@ class Bud_Card { ); $sql="insert into bud_card (bc_code,bc_description,bc_price_unit,bc_unit,bh_id) ". " values (substr($1,1,10),$2,$3,substr($4,1,20),$5) returning bc_id "; + try { + $a=ExecSqlParam($this->db,$sql,$array); + $x=pg_fetch_array($a,0); + $this->bc_id=$x['bc_id']; + } catch (Exception $e) { + if ( DEBUG===true ) print_r($e); + return 'Impossible de sauver'; - $a=ExecSqlParam($this->db,$sql,$array); - $x=pg_fetch_array($a,0); - $this->bc_id=$x['bc_id']; + } + return 'Sauve'; } function update() { @@ -81,26 +87,31 @@ class Bud_Card { $this->bc_unit, $this->bc_id ); - - ExecSqlParam($this->db,$sql,$array); - + try { + ExecSqlParam($this->db,$sql,$array); + }catch (Exception $e) { + if ( DEBUG === true ) print_r($e); + return 'Impossible de sauver'; + } + return 'Sauve'; } - /*! - *\brief convert an array to an object, if a idx is not set then the - * corresponding property will be null - * \param $p_array array to convert - */ + /*! + *\brief convert an array to an object, if a idx is not set then the + * corresponding property will be null + * \param $p_array array to convert + */ function from_array($p_array) { - if ( empty($p_array) ) return; - foreach (array ('bh_id','bc_id','bc_code','bc_description','bc_price_unit','bc_unit') - as $key ){ - $this->$key=(isset($p_array[$key]))?$p_array[$key]:null; - } -/* if ( $this->bc_id == null ) */ -/* throw new Exception(__FILE__.":".__LINE__." bc ne peut pas etre nul"); */ + if ( empty($p_array) ) return; + foreach (array ('bh_id','bc_id','bc_code','bc_description','bc_price_unit','bc_unit') + as $key ){ + $this->$key=(isset($p_array[$key]))?$p_array[$key]:null; + } + /* if ( $this->bc_id == null ) */ + /* throw new Exception(__FILE__.":".__LINE__." bc ne peut pas etre nul"); */ } function delete() { ExecSql($this->db,"delete from bud_card where bc_id=".$this->bc_id); + return 'Efface'; } function load()