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

Manage the table amortissement.amortissement_histo. More...

Collaboration diagram for Amortissement_Histo_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...
 
 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 amortissement.amortissement_histo.

Definition at line 38 of file class_amortissement_histo_sql.php.

Constructor & Destructor Documentation

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

Definition at line 48 of file class_amortissement_histo_sql.php.

References $key, ha_id, and load().

49  {
50  $this->cn=$p_cn;
51  $this->ha_id=$p_id;
52 
53  if ( $p_id == -1 )
54  {
55  /* Initialize an empty object */
56  foreach ($this->variable as $key=>$value) $this->$value='';
57  $this->ha_id=$p_id;
58  }
59  else
60  {
61  /* load it */
62 
63  $this->load();
64  }
65  }
$key
if($p_number->value==0) l les annuités seront recalculées et l pct[] ad_year[] select ha_id

Member Function Documentation

Amortissement_Histo_Sql::delete ( )

Definition at line 249 of file class_amortissement_histo_sql.php.

References $res, $sql, and ha_id.

250  {
251  $sql="delete from amortissement.amortissement_histo where ha_id=$1";
252  $res=$this->cn->exec_sql($sql,array($this->ha_id));
253  }
$res
$sql
if($p_number->value==0) l les annuités seront recalculées et l pct[] ad_year[] select ha_id
Amortissement_Histo_Sql::get_info ( )

Definition at line 86 of file class_amortissement_histo_sql.php.

87  {
88  return var_export($this,true);
89  }
Amortissement_Histo_Sql::get_parameter (   $p_string)

Definition at line 66 of file class_amortissement_histo_sql.php.

67  {
68  if ( array_key_exists($p_string,$this->variable) )
69  {
70  $idx=$this->variable[$p_string];
71  return $this->$idx;
72  }
73  else
74  throw new Exception (__FILE__.":".__LINE__.$p_string.'Erreur attribut inexistant');
75  }
Amortissement_Histo_Sql::insert ( )

Definition at line 138 of file class_amortissement_histo_sql.php.

References $sql, a_id, h_pj, ha_id, jr_internal, and verify().

Referenced by save().

139  {
140  if ( $this->verify() != 0 ) return;
141  if ( $this->ha_id==-1 )
142  {
143  /* please adapt */
144  $sql="insert into amortissement.amortissement_histo(a_id
145  ,h_amount
146  ,jr_internal
147  ,h_year
148  ,h_pj
149  ) values ($1
150  ,$2
151  ,$3
152  ,$4
153  ,$5
154  ) returning ha_id";
155 
156  $this->ha_id=$this->cn->get_value(
157  $sql,
158  array( $this->a_id
159  ,$this->h_amount
160  ,$this->jr_internal
161  ,$this->h_year
162  ,$this->h_pj
163  )
164  );
165  }
166  else
167  {
168  $sql="insert into amortissement.amortissement_histo(a_id
169  ,h_amount
170  ,jr_internal
171  ,h_year
172  ,h_pj
173  ,ha_id) values ($1
174  ,$2
175  ,$3
176  ,$4
177  ,$5
178  ,$6
179  ) returning ha_id";
180 
181  $this->ha_id=$this->cn->get_value(
182  $sql,
183  array( $this->a_id
184  ,$this->h_amount
185  ,$this->jr_internal
186  ,$this->h_year
187  ,$this->h_pj
188  ,$this->ha_id)
189  );
190 
191  }
192 
193  }
if($p_number->value==0) l les annuités seront recalculées et l pct[] ad_year[] select h_pj
$sql
if($p_number->value==0) l les annuités seront recalculées et l pct[] ad_year[] select ha_id
if($p_number->value==0) l les annuités seront recalculées et l pct[] ad_year[] select h_amount from amortissement amortissement_histo where a_id
if($p_number->value==0) l les annuités seront recalculées et l pct[] ad_year[] select jr_internal
Amortissement_Histo_Sql::load ( )

load a object

Returns
0 on success -1 the object is not found

Definition at line 220 of file class_amortissement_histo_sql.php.

References $key, $res, $sql, and ha_id.

Referenced by __construct().

221  {
222 
223  $sql="select a_id
224  ,h_amount
225  ,jr_internal
226  ,h_year
227  ,h_pj
228  from amortissement.amortissement_histo where ha_id=$1";
229  /* please adapt */
230  $res=$this->cn->get_array(
231  $sql,
232  array($this->ha_id)
233  );
234 
235  if ( count($res) == 0 )
236  {
237  /* Initialize an empty object */
238  foreach ($this->variable as $key=>$value) $this->$key='';
239 
240  return -1;
241  }
242  foreach ($res[0] as $idx=>$value)
243  {
244  $this->$idx=$value;
245  }
246  return 0;
247  }
$key
$res
$sql
if($p_number->value==0) l les annuités seront recalculées et l pct[] ad_year[] select ha_id
Amortissement_Histo_Sql::save ( )

Definition at line 103 of file class_amortissement_histo_sql.php.

References ha_id, insert(), and update().

104  {
105  /* please adapt */
106  if ( $this->ha_id == -1 )
107  $this->insert();
108  else
109  $this->update();
110  }
if($p_number->value==0) l les annuités seront recalculées et l pct[] ad_year[] select ha_id
Amortissement_Histo_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::get_array
Returns
an empty array if nothing is found

Definition at line 119 of file class_amortissement_histo_sql.php.

References $array, and $sql.

120  {
121  $sql="select * from amortissement.amortissement_histo $cond";
122  $aobj=array();
123  $array= $this->cn->get_array($sql,$p_array);
124  // map each row in a object
125  $size=$this->cn->count();
126  if ( $size == 0 ) return $aobj;
127  for ($i=0; $i<$size; $i++)
128  {
129  $oobj=new Amortissement_Histo_Sql ($this->cn);
130  foreach ($array[$i] as $idx=>$value)
131  {
132  $oobj->$idx=$value;
133  }
134  $aobj[]=clone $oobj;
135  }
136  return $aobj;
137  }
if(isset($_POST['remove'])) $array
Manage the table amortissement.amortissement_histo.
$sql
Amortissement_Histo_Sql::set_parameter (   $p_string,
  $p_value 
)

Definition at line 76 of file class_amortissement_histo_sql.php.

77  {
78  if ( array_key_exists($p_string,$this->variable) )
79  {
80  $idx=$this->variable[$p_string];
81  $this->$idx=$p_value;
82  }
83  else
84  throw new Exception (__FILE__.":".__LINE__.$p_string.'Erreur attribut inexistant');
85  }
static Amortissement_Histo_Sql::test_me ( )
static

Unit test for the class.

Definition at line 257 of file class_amortissement_histo_sql.php.

258  {
259 
260  }
Amortissement_Histo_Sql::update ( )

Definition at line 195 of file class_amortissement_histo_sql.php.

References $res, $sql, a_id, h_pj, ha_id, jr_internal, and verify().

Referenced by save().

196  {
197  if ( $this->verify() != 0 ) return;
198  /* please adapt */
199  $sql=" update amortissement.amortissement_histo set a_id = $1
200  ,h_amount = $2
201  ,jr_internal = $3
202  ,h_year = $4
203  ,h_pj = $5
204  where ha_id= $6";
205  $res=$this->cn->exec_sql(
206  $sql,
207  array($this->a_id
208  ,$this->h_amount
209  ,$this->jr_internal
210  ,$this->h_year
211  ,$this->h_pj
212  ,$this->ha_id)
213  );
214 
215  }
if($p_number->value==0) l les annuités seront recalculées et l pct[] ad_year[] select h_pj
$res
$sql
if($p_number->value==0) l les annuités seront recalculées et l pct[] ad_year[] select ha_id
if($p_number->value==0) l les annuités seront recalculées et l pct[] ad_year[] select h_amount from amortissement amortissement_histo where a_id
if($p_number->value==0) l les annuités seront recalculées et l pct[] ad_year[] select jr_internal
Amortissement_Histo_Sql::verify ( )

Definition at line 90 of file class_amortissement_histo_sql.php.

References a_id.

Referenced by insert(), and update().

91  {
92  // Verify that the elt we want to add is correct
93  /* verify only the datatype */
94  if ( settype($this->a_id,'float') == false )
95  throw new Exception('DATATYPE a_id $this->a_id non numerique');
96  if ( settype($this->h_amount,'float') == false )
97  throw new Exception('DATATYPE h_amount $this->h_amount non numerique');
98  if ( settype($this->h_year,'float') == false )
99  throw new Exception('DATATYPE h_year $this->h_year non numerique');
100 
101 
102  }
if($p_number->value==0) l les annuités seront recalculées et l pct[] ad_year[] select h_amount from amortissement amortissement_histo where a_id

Field Documentation

Amortissement_Histo_Sql::$variable
protected
Initial value:
=array("ha_id"=>"ha_id","a_id"=>"a_id"
,"h_amount"=>"h_amount"
,"jr_internal"=>"jr_internal"
,"h_year"=>"h_year"
,"h_pj"=>"h_pj"
)

Definition at line 42 of file class_amortissement_histo_sql.php.


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