db=$p_cn; $this->p_code=$p_id; if ( $p_id != -1 ) $this->Get(); } /*! ************************************************** * \brief * Load all parmCode * return an array of parm_code object * * \return array */ function LoadAll() { $sql="select * from parm_code order by p_code"; $Res=ExecSql($this->db,$sql); $r= pg_fetch_all($Res); $idx=0; $array=array(); if ( $r === false ) return null; foreach ($r as $row ) { $o=new parm_code($this->db,$row['p_code']); $array[$idx]=$o; $idx++; } return $array; } /*! ************************************************** * \brief update a parm_object into the database * p_code is _not_ updatable * \return * nothing */ function Save() { // if p_code=="" nothing to save if ( $this->p_code== -1) return; $this->p_comment=FormatString($this->p_comment); $this->p_value=FormatString($this->p_value); $this->p_code=FormatString($this->p_code); $sql="update parm_code set ". "p_comment='".$this->p_comment."' ". ",p_value='".$this->p_value."' ". "where p_code='".$this->p_code."'"; $Res=ExecSql($this->db,$sql); } /*! ************************************************** * \brief Display an object, with the tag * * \return * string */ function Display() { $r=""; $r.= ''.$this->p_code.''; $r.= ''.$this->p_comment.''; $r.= ''.$this->p_value.''; return $r; } /*! ************************************************** * \brief Display a form to enter info about * a parm_code object with the tag * * \return string */ function Input() { $comment=new widget("text"); $comment->name='p_comment'; $comment->value=$this->p_comment; $value=new widget("text"); $value->name='p_value'; $value->value=$this->p_value; $poste=new widget("text"); $poste->SetReadOnly(true); $poste->name='p_code'; $poste->value=$this->p_code; $r=""; $r.= ''.$poste->IOValue().''; $r.= ''.$comment->IOValue().''; $r.= ''.$value->IOValue().''; return $r; } /*! ************************************************** * \brief * Complete a parm_code object thanks the p_code * * \return array */ function Get() { if ( $this->p_code == -1 ) return "p_code non initialisé"; $sql=sprintf("select * from parm_code where p_code='%s' ", $this->p_code); $Res=ExecSql($this->db,$sql); if ( pg_NumRows($Res) == 0 ) return 'INCONNU'; $row= pg_fetch_array($Res,0); $this->p_value=$row['p_value']; $this->p_comment=$row['p_comment']; } }