db=$p_cn; $this->bd_id=$id; $this->po_id=null;$this->bc_id=null;$this->pcm_val=null; } function add () { $array=array($this->po_id, $this->bc_id, $this->pcm_val); $sql="insert into bud_detail (po_id,bc_id,pcm_val) ". " values ($1,$2,$3) returning bd_id "; $a=ExecSqlParam($this->db,$sql,$array); $x=pg_fetch_array($a,0); $this->bd_id=$x['bd_id']; } function update() { if ( $this->bd_id == 0) return; $sql="update bud_detail set po_id=$1,". "bc_id=$2,". "pcm_val=$3 ". " where bd_id=$4"; $array=array($this->po_id, $this->bc_id, $this->pcm_val, $this->bd_id ); ExecSqlParam($this->db,$sql,$array); } function delete() { ExecSql($this->db,"delete from bud_detail where bd_id=".$this->bd_id); } function load() { if ( $this->bd_id == 0 ) return ; $sql="select * ". " from bud_detail ". " where ". " bd_id =".$this->bd_id; $res=ExecSql($this->db,$sql); if ( pg_NumRows($res) == 0 ) return; $a=pg_fetch_array($res,0); foreach ( array('bc_id','po_id','pcm_val') as $key) { $this->{"$key"}=$a[$key]; } } static function get_list($p_cn,$p_bh_id,$pa_id=0) { $pa_filter=($pa_id)?" and pa_id = $pa_id ":""; $sql="select * from bud_detail join bud_detail_periode using(bd_id) ". " right join parm_periode using (p_id) ". " where bh_id= $bh_id $pa_filter " } static function testme() { $cn=DbConnect(dossier::id()); $a=new Bud_Detail($cn); $a->po_id=4; echo "

Ajout d'un bud_detail

"; $a->add(); print_r($a); echo "

Mise a jour d'un bud_detail

"; $a->pcm_val='55'; $a->update(); print_r($a); echo "

Load

"; $b=new Bud_Detail($cn); $b->bd_id=$a->bd_id; $b->load(); print_r($b); echo "

Effacement

"; $a->delete(); } }