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

Manage the table importbank.format_bank. More...

Collaboration diagram for Format_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.format_bank.

Definition at line 36 of file class_format_bank_sql.php.

Constructor & Destructor Documentation

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

Definition at line 55 of file class_format_bank_sql.php.

References $key, and load().

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

Member Function Documentation

Format_Bank_sql::delete ( )

Definition at line 362 of file class_format_bank_sql.php.

References $res, and $sql.

363  {
364  $sql="delete from importbank.format_bank where id=$1";
365  $res=$this->cn->exec_sql($sql,array($this->id));
366  }
$res
$sql
Format_Bank_sql::get_info ( )

Definition at line 93 of file class_format_bank_sql.php.

94  {
95  return var_export($this,true);
96  }
Format_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 146 of file class_format_bank_sql.php.

References $array.

147  {
148  // map each row in a object
149  $oobj=new Format_Bank_sql ($this->cn);
150  $array=Database::fetch_array($p_ret,$idx);
151  foreach ($array as $idx=>$value)
152  {
153  $oobj->$idx=$value;
154  }
155  $aobj[]=clone $oobj;
156 
157  return $aobj;
158  }
Manage the table importbank.format_bank.
if(isset($_POST['remove'])) $array
Format_Bank_sql::get_parameter (   $p_string)

Definition at line 73 of file class_format_bank_sql.php.

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

Definition at line 159 of file class_format_bank_sql.php.

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

Referenced by save().

160  {
161  if ( $this->verify() != 0 ) return;
162  if ( strlen(trim($this->format_name))==0)
163  {
164  $get_id=$this->cn->get_value('select id from importbank.format_bank where format_name=$1',array($this->format_name));
165  if ( $this->cn->size() == 1) {
166  $this->update();
167  return;
168  }
169 
170  }
171  if ( $this->id==-1 )
172  {
173  /* please adapt */
174  $sql="insert into importbank.format_bank(format_name
175  ,jrn_def_id
176  ,pos_lib
177  ,pos_amount
178  ,pos_date
179  ,pos_operation_nb
180  ,pos_third
181  ,pos_extra
182  ,sep_decimal
183  ,sep_thousand
184  ,sep_field
185  ,format_date
186  ,nb_col
187  ,skip
188  ) values ($1
189  ,$2
190  ,$3
191  ,$4
192  ,$5
193  ,$6
194  ,$7
195  ,$8
196  ,$9
197  ,$10
198  ,$11
199  ,$12
200  ,$13
201  ,$14
202  ) returning id";
203 
204  $this->id=$this->cn->get_value(
205  $sql,
206  array( $this->format_name
207  ,$this->jrn_def_id
208  ,$this->pos_lib
209  ,$this->pos_amount
210  ,$this->pos_date
211  ,$this->pos_operation_nb
212  ,$this->pos_third
213  ,$this->pos_extra
214  ,$this->sep_decimal
215  ,$this->sep_thousand
216  ,$this->sep_field
217  ,$this->format_date
218  ,$this->nb_col
219  ,$this->skip
220  )
221  );
222  }
223  else
224  {
225  $sql="insert into importbank.format_bank(format_name
226  ,jrn_def_id
227  ,pos_lib
228  ,pos_amount
229  ,pos_date
230  ,pos_operation_nb
231  ,pos_third
232  ,pos_extra
233  ,sep_decimal
234  ,sep_thousand
235  ,sep_field
236  ,format_date
237  ,nb_col
238  ,id
239  ,skip
240  ) values ($1
241  ,$2
242  ,$3
243  ,$4
244  ,$5
245  ,$6
246  ,$7
247  ,$8
248  ,$9
249  ,$10
250  ,$11
251  ,$12
252  ,$13
253  ,$14
254  ,$15
255  ) returning id";
256 
257  $this->id=$this->cn->get_value(
258  $sql,
259  array( $this->format_name
260  ,$this->jrn_def_id
261  ,$this->pos_lib
262  ,$this->pos_amount
263  ,$this->pos_date
264  ,$this->pos_operation_nb
265  ,$this->pos_third
266  ,$this->pos_extra
267  ,$this->sep_decimal
268  ,$this->sep_thousand
269  ,$this->sep_field
270  ,$this->format_date
271  ,$this->nb_col
272  ,$this->id
273  ,$this->skip
274  )
275  );
276 
277  }
278 
279  }
$sql
Format_Bank_sql::load ( )

load a object

Returns
0 on success -1 the object is not found

Definition at line 324 of file class_format_bank_sql.php.

References $key, $res, and $sql.

Referenced by __construct().

325  {
326 
327  $sql="select format_name
328  ,jrn_def_id
329  ,pos_lib
330  ,pos_amount
331  ,pos_date
332  ,pos_operation_nb
333  ,pos_third
334  ,pos_extra
335  ,sep_decimal
336  ,sep_thousand
337  ,sep_field
338  ,format_date
339  ,nb_col
340  ,skip
341  from importbank.format_bank where id=$1";
342  /* please adapt */
343  $res=$this->cn->get_array(
344  $sql,
345  array($this->id)
346  );
347 
348  if ( count($res) == 0 )
349  {
350  /* Initialize an empty object */
351  foreach ($this->variable as $key=>$value) $this->$key='';
352 
353  return -1;
354  }
355  foreach ($res[0] as $idx=>$value)
356  {
357  $this->$idx=$value;
358  }
359  return 0;
360  }
$key
$res
$sql
Format_Bank_sql::save ( )

Definition at line 115 of file class_format_bank_sql.php.

References insert(), and update().

116  {
117  /* please adapt */
118  if ( $this->id == -1 )
119  $this->insert();
120  else
121  $this->update();
122  }
Format_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 131 of file class_format_bank_sql.php.

References $ret, and $sql.

132  {
133  $sql="select * from importbank.format_bank $cond";
134  $aobj=array();
135  $ret= $this->cn->exec_sql($sql,$p_array);
136  return $ret;
137  }
$ret
$sql
Format_Bank_sql::set_parameter (   $p_string,
  $p_value 
)

Definition at line 83 of file class_format_bank_sql.php.

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

Unit test for the class.

Definition at line 370 of file class_format_bank_sql.php.

371  {
372 
373  }
Format_Bank_sql::update ( )

Definition at line 281 of file class_format_bank_sql.php.

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

Referenced by insert(), and save().

282  {
283  if ( $this->verify() != 0 ) return;
284  /* please adapt */
285  $sql=" update importbank.format_bank set format_name = $1
286  ,jrn_def_id = $2
287  ,pos_lib = $3
288  ,pos_amount = $4
289  ,pos_date = $5
290  ,pos_operation_nb = $6
291  ,pos_third = $7
292  ,pos_extra=$8
293  ,sep_decimal = $9
294  ,sep_thousand = $10
295  ,sep_field = $11
296  ,format_date = $12
297  ,nb_col = $13
298  ,skip=$14
299  where id= $15";
300  $res=$this->cn->exec_sql(
301  $sql,
302  array($this->format_name
303  ,$this->jrn_def_id
304  ,$this->pos_lib
305  ,$this->pos_amount
306  ,$this->pos_date
307  ,$this->pos_operation_nb
308  ,$this->pos_third
309  ,$this->pos_extra
310  ,$this->sep_decimal
311  ,$this->sep_thousand
312  ,$this->sep_field
313  ,$this->format_date
314  ,$this->nb_col
315  ,$this->skip
316  ,$this->id)
317  );
318 
319  }
$res
$sql
Format_Bank_sql::verify ( )

Definition at line 97 of file class_format_bank_sql.php.

Referenced by insert(), and update().

98  {
99  // Verify that the elt we want to add is correct
100  /* verify only the datatype */
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 ( $this->pos_lib !== null && settype($this->pos_lib,'float') == false )
104  throw new Exception('DATATYPE pos_lib $this->pos_lib non numerique');
105  if ( $this->pos_amount !== null && settype($this->pos_amount,'float') == false )
106  throw new Exception('DATATYPE pos_amount $this->pos_amount non numerique');
107  if ( $this->pos_date !== null && settype($this->pos_date,'float') == false )
108  throw new Exception('DATATYPE pos_date $this->pos_date non numerique');
109  if ( $this->pos_operation_nb !== null && settype($this->pos_operation_nb,'float') == false )
110  throw new Exception('DATATYPE pos_operation_nb $this->pos_operation_nb non numerique');
111  if ($this->nb_col !== null && settype($this->nb_col,'float') == false )
112  throw new Exception('DATATYPE nb_col $this->nb_col non numerique');
113 
114  }

Field Documentation

Format_Bank_sql::$variable
protected
Initial value:
=array("id"=>"id","format_name"=>"format_name"
,"jrn_def_id"=>"jrn_def_id"
,"pos_lib"=>"pos_lib"
,"pos_amount"=>"pos_amount"
,"pos_date"=>"pos_date"
,"pos_operation_nb"=>"pos_operation_nb"
,"pos_third"=>"pos_third"
,"pos_extra"=>"pos_extra"
,"sep_decimal"=>"sep_decimal"
,"sep_thousand"=>"sep_thousand"
,"sep_field"=>"sep_field"
,"format_date"=>"format_date"
,"nb_col"=>"nb_col"
,"skip"=>"skip"
)

Definition at line 40 of file class_format_bank_sql.php.


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