Plugins  LAST
 All Data Structures Files Functions Variables Pages
Public Member Functions | Static Public Member Functions | Protected Attributes
Temp_Bank_sql Class Reference

Manage the table importbank.temp_bank. More...

Collaboration diagram for Temp_Bank_sql:
Collaboration graph

Public Member Functions

 __construct (&$p_cn, $p_id=-1)
 
 get_parameter ($p_string)
 
 set_parameter ($p_string, $p_value)
 
 get_info ()
 
 verify ()
 
 save ()
 
 seek ($cond='', $p_array=null)
 retrieve array of object thanks a condition More...
 
 get_object ($p_ret, $idx)
 get_seek return the next object, the return of the query must have all the column of the object More...
 
 insert ()
 
 update ()
 
 load ()
 load a object More...
 
 delete ()
 

Static Public Member Functions

static test_me ()
 Unit test for the class. More...
 

Protected Attributes

 $variable
 

Detailed Description

Manage the table importbank.temp_bank.

Definition at line 36 of file class_temp_bank_sql.php.

Constructor & Destructor Documentation

Temp_Bank_sql::__construct ( $p_cn,
  $p_id = -1 
)

Definition at line 53 of file class_temp_bank_sql.php.

References $key, and load().

54  {
55  $this->cn=$p_cn;
56  $this->id=$p_id;
57 
58  if ( $p_id == -1 )
59  {
60  /* Initialize an empty object */
61  foreach ($this->variable as $key=>$value) $this->$value=null;
62  $this->id=$p_id;
63  }
64  else
65  {
66  /* load it */
67 
68  $this->load();
69  }
70  }
load()
load a object
$key

Member Function Documentation

Temp_Bank_sql::delete ( )

Definition at line 340 of file class_temp_bank_sql.php.

References $res, and $sql.

341  {
342  $sql="delete from importbank.temp_bank where id=$1";
343  $res=$this->cn->exec_sql($sql,array($this->id));
344  }
$res
$sql
Temp_Bank_sql::get_info ( )

Definition at line 91 of file class_temp_bank_sql.php.

92  {
93  return var_export($this,true);
94  }
Temp_Bank_sql::get_object (   $p_ret,
  $idx 
)

get_seek return the next object, the return of the query must have all the column of the object

Parameters
$p_retis the return value of an exec_sql
$idxis the index
See Also
seek
Returns
object

Definition at line 151 of file class_temp_bank_sql.php.

References $array.

152  {
153  // map each row in a object
154  $oobj=new Temp_Bank_sql ($this->cn);
155  $array=Database::fetch_array($p_ret,$idx);
156  foreach ($array as $idx=>$value)
157  {
158  $oobj->$idx=$value;
159  }
160  $aobj[]=clone $oobj;
161 
162  return $aobj;
163  }
Manage the table importbank.temp_bank.
if(isset($_POST['remove'])) $array
Temp_Bank_sql::get_parameter (   $p_string)

Definition at line 71 of file class_temp_bank_sql.php.

72  {
73  if ( array_key_exists($p_string,$this->variable) )
74  {
75  $idx=$this->variable[$p_string];
76  return $this->$idx;
77  }
78  else
79  throw new Exception (__FILE__.":".__LINE__.$p_string.'Erreur attribut inexistant');
80  }
Temp_Bank_sql::insert ( )

Definition at line 164 of file class_temp_bank_sql.php.

References $sql, and verify().

Referenced by save().

165  {
166  if ( $this->verify() != 0 ) return;
167  if ( $this->id==-1 )
168  {
169  /* please adapt */
170  $sql="insert into importbank.temp_bank(tp_date
171  ,jrn_def_id
172  ,libelle
173  ,amount
174  ,ref_operation
175  ,status
176  ,import_id
177  ,tp_third
178  ,tp_extra
179  ,f_id
180  ,tp_rec
181  ,tp_error_msg
182  ) values (to_date($1,'DD.MM.YYYY')
183  ,$2
184  ,$3
185  ,$4
186  ,$5
187  ,$6
188  ,$7
189  ,$8
190  ,$9
191  ,$10
192  ,$11
193  ,$12
194 
195  ) returning id";
196 
197  $this->id=$this->cn->get_value(
198  $sql,
199  array( $this->tp_date
200  ,$this->jrn_def_id
201  ,$this->libelle
202  ,$this->amount
203  ,$this->ref_operation
204  ,$this->status
205  ,$this->import_id
206  ,$this->tp_third
207  ,$this->tp_extra
208  ,$this->f_id
209  ,$this->tp_rec
210  ,$this->tp_error_msg
211 
212  )
213  );
214  }
215  else
216  {
217  $sql="insert into importbank.temp_bank(tp_date
218  ,jrn_def_id
219  ,libelle
220  ,amount
221  ,ref_operation
222  ,status
223  ,import_id
224  ,tp_third
225  ,tp_extra
226  ,f_id
227  ,id) values (to_date($1,'DD.MM.YYYY')
228  ,$2
229  ,$3
230  ,$4
231  ,$5
232  ,$6
233  ,$7
234  ,$8
235  ,$9
236  ,$10
237  ,$11
238  ,$12
239  ,$13
240  ) returning id";
241 
242  $this->id=$this->cn->get_value(
243  $sql,
244  array( $this->tp_date
245  ,$this->jrn_def_id
246  ,$this->libelle
247  ,$this->amount
248  ,$this->ref_operation
249  ,$this->status
250  ,$this->import_id
251  ,$this->tp_third
252  ,$this->tp_extra
253  ,$this->f_id
254  ,$this->id
255  ,$this->tp_rec
256  ,$this->tp_error_msg
257  )
258  );
259 
260  }
261 
262  }
$sql
Temp_Bank_sql::load ( )

load a object

Returns
0 on success -1 the object is not found

Definition at line 304 of file class_temp_bank_sql.php.

References $key, $res, and $sql.

Referenced by __construct().

305  {
306 
307  $sql="select to_char(tp_date,'DD.MM.YYYY') as tp_date
308  ,jrn_def_id
309  ,libelle
310  ,amount
311  ,ref_operation
312  ,status
313  ,import_id
314  ,tp_third
315  ,tp_extra
316  ,f_id
317  ,tp_rec
318  ,tp_error_msg
319  from importbank.temp_bank where id=$1";
320  /* please adapt */
321  $res=$this->cn->get_array(
322  $sql,
323  array($this->id)
324  );
325 
326  if ( count($res) == 0 )
327  {
328  /* Initialize an empty object */
329  foreach ($this->variable as $key=>$value) $this->$key='';
330 
331  return -1;
332  }
333  foreach ($res[0] as $idx=>$value)
334  {
335  $this->$idx=$value;
336  }
337  return 0;
338  }
$key
$res
$sql
Temp_Bank_sql::save ( )

Definition at line 120 of file class_temp_bank_sql.php.

References insert(), and update().

121  {
122  /* please adapt */
123  if ( $this->id == -1 )
124  $this->insert();
125  else
126  $this->update();
127  }
Temp_Bank_sql::seek (   $cond = '',
  $p_array = null 
)

retrieve array of object thanks a condition

Parameters
$condcondition (where clause) (optional by default all the rows are fetched) you can use this parameter for the order or subselect
$p_arrayarray for the SQL stmt
See Also
Database::exec_sql get_object Database::num_row
Returns
the return value of exec_sql

Definition at line 136 of file class_temp_bank_sql.php.

References $ret, and $sql.

137  {
138  $sql="select * from importbank.temp_bank $cond";
139  $aobj=array();
140  $ret= $this->cn->exec_sql($sql,$p_array);
141  return $ret;
142  }
$ret
$sql
Temp_Bank_sql::set_parameter (   $p_string,
  $p_value 
)

Definition at line 81 of file class_temp_bank_sql.php.

82  {
83  if ( array_key_exists($p_string,$this->variable) )
84  {
85  $idx=$this->variable[$p_string];
86  $this->$idx=$p_value;
87  }
88  else
89  throw new Exception (__FILE__.":".__LINE__.$p_string.'Erreur attribut inexistant');
90  }
static Temp_Bank_sql::test_me ( )
static

Unit test for the class.

Definition at line 348 of file class_temp_bank_sql.php.

References $cn, and $obj.

349  {
350  $cn=new Database(25);
351  $cn->start();
352  echo h2info('Test object vide');
353  $obj=new Temp_Bank_sql($cn);
354  var_dump($obj);
355 
356  echo h2info('Test object NON vide');
357  $obj->set_parameter('j_id',3);
358  $obj->load();
359  var_dump($obj);
360 
361  echo h2info('Update');
362  $obj->set_parameter('j_qcode','NOUVEAU CODE');
363  $obj->save();
364  $obj->load();
365  var_dump($obj);
366 
367  echo h2info('Insert');
368  $obj->set_parameter('j_id',0);
369  $obj->save();
370  $obj->load();
371  var_dump($obj);
372 
373  echo h2info('Delete');
374  $obj->delete();
375  echo (($obj->load()==0)?'Trouve':'non trouve');
376  var_dump($obj);
377  $cn->rollback();
378 
379  }
Manage the table importbank.temp_bank.
global $cn
Temp_Bank_sql::update ( )

Definition at line 264 of file class_temp_bank_sql.php.

References $res, $sql, and verify().

Referenced by save().

265  {
266 
267  if ( $this->verify() != 0 ) return;
268  /* please adapt */
269  $sql=" update importbank.temp_bank set tp_date =to_date($1,'DD.MM.YYYY')
270  ,jrn_def_id = $2
271  ,libelle = $3
272  ,amount = $4
273  ,ref_operation = $5
274  ,status = $6
275  ,import_id = $7
276  ,tp_third = $8
277  ,tp_extra = $9
278  ,f_id = $10
279  ,tp_rec=$11
280  ,tp_error_msg=$12
281  where id= $13";
282  $res=$this->cn->exec_sql(
283  $sql,
284  array($this->tp_date
285  ,$this->jrn_def_id
286  ,$this->libelle
287  ,$this->amount
288  ,$this->ref_operation
289  ,$this->status
290  ,$this->import_id
291  ,$this->tp_third
292  ,$this->tp_extra
293  ,$this->f_id
294  ,$this->tp_rec
295  ,$this->tp_error_msg
296  ,$this->id)
297  );
298 
299  }
$res
$sql
Temp_Bank_sql::verify ( )

Definition at line 95 of file class_temp_bank_sql.php.

Referenced by insert(), and update().

96  {
97  // Verify that the elt we want to add is correct
98  /* verify only the datatype */
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');
117 
118 
119  }

Field Documentation

Temp_Bank_sql::$variable
protected
Initial value:
=array("id"=>"id","tp_date"=>"tp_date"
,"jrn_def_id"=>"jrn_def_id"
,"libelle"=>"libelle"
,"amount"=>"amount"
,"ref_operation"=>"ref_operation"
,"status"=>"status"
,"import_id"=>"import_id"
,"tp_third"=>"tp_third"
,"tp_extra"=>"tp_extra"
,"f_id"=>"f_id"
,"tp_rec"=>"tp_rec"
,"tp_error_msg"=>"tp_error_msg"
)

Definition at line 40 of file class_temp_bank_sql.php.


The documentation for this class was generated from the following file: