db=$p_cn; $this->id=$p_id; $this->name=""; $this->description=""; $this->get(); } /*!\brief get the list of all existing PA * \return an array of PA (not object) * */ function get_list($p_order=" order by pa_name") { $array=array(); $sql="select pa_id as id,pa_name as name,". "pa_description as description from plan_analytique $p_order"; $ret=$this->db->exec_sql($sql); $array=Database::fetch_all($ret); return $array; } function get() { if ( $this->id==0) return; $sql="select pa_name,pa_description from plan_analytique where pa_id=$1"; $ret= $this->db->exec_sql($sql,array($this->id)); if ( Database::num_row($ret) == 0) { return; } $a= Database::fetch_array($ret,0); $this->name=$a['pa_name']; $this->description=$a['pa_description']; } function delete() { if ( $this->id == 0 ) return; $this->db->exec_sql("delete from plan_analytique where pa_id=$1",array($this->id)); } function update() { if ( $this->id==0) return; $name=sql_string($this->name); if ( strlen($name) == 0) return; $description=sql_string($this->description); $this->db->exec_sql("update plan_analytique set pa_name=$1, pa_description=$2 where pa_id=$3",array($name,$description,$this->id)); } function add() { $name=sql_string($this->name); if ( strlen($name) == 0) return; if ( $this->isAppend() == false) return; $description=sql_string($this->description); $this->db->exec_sql("insert into plan_analytique(pa_name,pa_description)". " values ($1,$2 )" ,array($name,$description)); $this->id=$this->db->get_current_seq('plan_analytique_pa_id_seq'); } function form() { $wName=new IText('pa_name',$this->name); $wName->table=1; $wDescription=new IText('pa_description',$this->description); $wDescription->table=1; $wId=new IHidden("pa_id",$this->id); $ret="