29 require_once NOALYSS_INCLUDE.
'/lib/class_database.php';
30 require_once NOALYSS_INCLUDE.
'/lib/ac_common.php';
40 protected $variable=array(
"id"=>
"id",
"tp_date"=>
"tp_date"
41 ,
"jrn_def_id"=>
"jrn_def_id"
44 ,
"ref_operation"=>
"ref_operation"
46 ,
"import_id"=>
"import_id"
47 ,
"tp_third"=>
"tp_third"
48 ,
"tp_extra"=>
"tp_extra"
51 ,
"tp_error_msg"=>
"tp_error_msg"
61 foreach ($this->variable as
$key=>$value) $this->$value=null;
73 if ( array_key_exists($p_string,$this->variable) )
75 $idx=$this->variable[$p_string];
79 throw new Exception (__FILE__.
":".__LINE__.$p_string.
'Erreur attribut inexistant');
83 if ( array_key_exists($p_string,$this->variable) )
85 $idx=$this->variable[$p_string];
89 throw new Exception (__FILE__.
":".__LINE__.$p_string.
'Erreur attribut inexistant');
93 return var_export($this,
true);
99 if ( trim($this->tp_date) ==
'') $this->tp_date=null;
100 if ( trim($this->jrn_def_id) ==
'') $this->jrn_def_id=null;
101 if ( $this->jrn_def_id!== null && settype($this->jrn_def_id,
'float') ==
false )
102 throw new Exception(
'DATATYPE jrn_def_id $this->jrn_def_id non numerique');
103 if ( trim($this->libelle) ==
'') $this->libelle=null;
104 if ( trim($this->amount) ==
'') $this->amount=null;
105 if ( $this->amount!== null && settype($this->amount,
'float') ==
false )
106 throw new Exception(
'DATATYPE amount $this->amount non numerique');
107 if ( trim($this->ref_operation) ==
'') $this->ref_operation=null;
108 if ( trim($this->status) ==
'') $this->status=null;
109 if ( trim($this->import_id) ==
'') $this->import_id=null;
110 if ( $this->import_id!== null && settype($this->import_id,
'float') ==
false )
111 throw new Exception(
'DATATYPE import_id $this->import_id non numerique');
112 if ( trim($this->tp_third) ==
'') $this->tp_third=null;
113 if ( trim($this->tp_extra) ==
'') $this->tp_extra=null;
114 if ( trim($this->f_id) ==
'') $this->f_id=null;
115 if ( $this->f_id!== null && settype($this->f_id,
'float') ==
false )
116 throw new Exception(
'DATATYPE f_id $this->f_id non numerique');
123 if ( $this->
id == -1 )
136 public function seek($cond=
'',$p_array=null)
138 $sql=
"select * from importbank.temp_bank $cond";
140 $ret= $this->cn->exec_sql(
$sql,$p_array);
155 $array=Database::fetch_array($p_ret,$idx);
156 foreach (
$array as $idx=>$value)
166 if ( $this->
verify() != 0 )
return;
170 $sql=
"insert into importbank.temp_bank(tp_date
182 ) values (to_date($1,'DD.MM.YYYY')
197 $this->
id=$this->cn->get_value(
199 array( $this->tp_date
203 ,$this->ref_operation
217 $sql=
"insert into importbank.temp_bank(tp_date
227 ,id) values (to_date($1,'DD.MM.YYYY')
242 $this->
id=$this->cn->get_value(
244 array( $this->tp_date
248 ,$this->ref_operation
267 if ( $this->
verify() != 0 )
return;
269 $sql=
" update importbank.temp_bank set tp_date =to_date($1,'DD.MM.YYYY')
282 $res=$this->cn->exec_sql(
288 ,$this->ref_operation
307 $sql=
"select to_char(tp_date,'DD.MM.YYYY') as tp_date
319 from importbank.temp_bank where id=$1";
321 $res=$this->cn->get_array(
326 if ( count(
$res) == 0 )
329 foreach ($this->variable as
$key=>$value) $this->
$key=
'';
333 foreach (
$res[0] as $idx=>$value)
340 public function delete()
342 $sql=
"delete from importbank.temp_bank where id=$1";
343 $res=$this->cn->exec_sql(
$sql,array($this->
id));
350 $cn=
new Database(25);
352 echo h2info(
'Test object vide');
356 echo h2info(
'Test object NON vide');
357 $obj->set_parameter(
'j_id',3);
361 echo h2info(
'Update');
362 $obj->set_parameter(
'j_qcode',
'NOUVEAU CODE');
367 echo h2info(
'Insert');
368 $obj->set_parameter(
'j_id',0);
373 echo h2info(
'Delete');
375 echo ((
$obj->load()==0)?
'Trouve':
'non trouve');
Manage the table importbank.temp_bank.
get_object($p_ret, $idx)
get_seek return the next object, the return of the query must have all the column of the object ...
__construct(&$p_cn, $p_id=-1)
seek($cond='', $p_array=null)
retrieve array of object thanks a condition
if(isset($_POST['remove'])) $array
static test_me()
Unit test for the class.
set_parameter($p_string, $p_value)