"fo_label", "formula"=>"fo_formula", "id"=>"fo_id", "position"=>"fo_pos", "form_id"=>"fo_fr_id", "database"=>"db" ); function __construct ($p_name=null,$p_formula=null) { $this->set_parameter("id",0); $this->set_parameter("name",$p_name); $this->set_parameter("formula",$p_formula); } public function get_parameter($p_string) { if ( array_key_exists($p_string,self::$variable) ) { $idx=self::$variable[$p_string]; return $this->$idx; } else throw new Exception("Attribut inexistant $p_string"); } public function set_parameter($p_string,$p_value) { if ( array_key_exists($p_string,self::$variable) ) { $idx=self::$variable[$p_string]; $this->$idx=$p_value; } else throw new Exception("Attribut inexistant $p_string"); } public function get_info() { return var_export(self::$variable,true); } /*!\brief Convert an array into an array of row_rapport object * the fo_id is 0, position = 0, the fo_frd_id (form_id) is * the one of the current object, the db is also the current one *\param $p_array contains the value *\return an array of Acc_Report_Row object */ public function from_array($p_array) { extract ($p_array); $ret=array(); $ix=0; $found=0; foreach ( $p_array as $r) { if ( isset(${'form'.$ix}) && isset ( ${'text'.$ix} )) { $obj=new Acc_Report_Row( ${'text'.$ix},${'form'.$ix}); if ( isset(${'pos'.$ix}) && isNumber(${'pos'.$ix})==1 ) $obj->set_parameter("position",${'pos'.$ix}); else { $obj->set_parameter("position",$found); $found++; } $obj->fo_id=0; $obj->fo_fr_id=$this->fo_fr_id; $obj->db=$this->db; $ret[]=clone $obj; } $ix++; } return $ret; } static function test_me() { $cn=new Database(dossier::id()); $a=new Acc_Report_Row(); $array=array("text0"=>"test1", "form0"=>"7%", "text1"=>"test2", "form1"=>"6%" ); $a->db=$cn; $b=$a->from_array($array); print_r($b); echo $a->get_info(); } }