From f9a4c048a0c55e2d1988db841501be8f53aef8a0 Mon Sep 17 00:00:00 2001 From: sparkyx Date: Wed, 12 Dec 2007 19:18:26 +0000 Subject: [PATCH] add a static testme function --- include/class_poste_analytic.php | 49 ++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/include/class_poste_analytic.php b/include/class_poste_analytic.php index 1d9d438b6..cde7129cb 100644 --- a/include/class_poste_analytic.php +++ b/include/class_poste_analytic.php @@ -43,6 +43,7 @@ class Poste_analytique { $this->db=$p_db; $this->id=$p_id; + $this->ga_id=null; } /*! \brief retrieve data from the database and * fill the object @@ -96,6 +97,10 @@ class Poste_analytique $this->format_data(); if ( strlen($this->name) == 0) return; + if ( $this->ga_id == null || strlen(trim($this->ga_id)) == 0 ) + $ga_id="NULL"; + else + $ga_id="'".$this->ga_id."'"; $sql="insert into poste_analytique ( po_name , pa_id, @@ -107,7 +112,7 @@ class Poste_analytique $this->pa_id.",". $this->amount.",". "'".$this->description."',". - "'".$this->ga_id."')"; + $ga_id.")"; try { ExecSql($this->db,$sql); @@ -190,7 +195,7 @@ class Poste_analytique function display_list() { $array=$this->get_list(); - + if ( empty($array) ) { echo "Vide"; return;} foreach ($array as $line) { echo $line->id." / ".$line->name." / ".$line->description."/". @@ -267,5 +272,45 @@ class Poste_analytique $this->id=$_POST['po_id']; $this->ga_id=($_POST['ga_id'] == "-1" )?"":$_POST['ga_id']; } + static function testme() { + $cn=DbConnect(dossier::id()); + $o=new Poste_Analytique($cn); + echo "

Poste_Analytique

"; + echo "

get_list

"; + $ee=$o->get_list(); + print_r($ee); + //var_dump($ee); + $pa_id=26; + echo "

Add some

"; + $o->pa_id=$pa_id; + $o->name="test1"; + $o->add(); + + + $o->name="test2"; + $o->add(); + + $o->name="test3"; + $o->add(); + + $o->name="test4"; + $o->add(); + + $o->name="test5"; + $o->add(); + + echo "

remove test1

"; + $o->get_by_name("test1"); + $o->delete(); + $o->display_list(); + + $o->get_by_name("test4"); + echo "
".$o->id."
"; + $o->name="Test Four"; + $o->update(); + $o->display_list(); + $o->delete(); + $o->display_list(); + } } ?>