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

Manage the table amortissement.amortissement_detail. More...

Collaboration diagram for Amortissement_Detail_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_detail.

Definition at line 36 of file class_amortissement_detail_sql.php.

Constructor & Destructor Documentation

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

Definition at line 45 of file class_amortissement_detail_sql.php.

References $key, and load().

46  {
47  $this->cn=$p_cn;
48  $this->ad_id=$p_id;
49 
50  if ( $p_id == -1 )
51  {
52  /* Initialize an empty object */
53  foreach ($this->variable as $key=>$value) $this->$value='';
54  $this->ad_id=$p_id;
55  }
56  else
57  {
58  /* load it */
59 
60  $this->load();
61  }
62  }
$key

Member Function Documentation

Amortissement_Detail_Sql::delete ( )

Definition at line 239 of file class_amortissement_detail_sql.php.

References $res, and $sql.

240  {
241  $sql="delete from amortissement.amortissement_detail where ad_id=$1";
242  $res=$this->cn->exec_sql($sql,array($this->ad_id));
243  }
$res
$sql
Amortissement_Detail_Sql::get_info ( )

Definition at line 83 of file class_amortissement_detail_sql.php.

84  {
85  return var_export($this,true);
86  }
Amortissement_Detail_Sql::get_parameter (   $p_string)

Definition at line 63 of file class_amortissement_detail_sql.php.

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

Definition at line 137 of file class_amortissement_detail_sql.php.

References $sql, a_id, and verify().

Referenced by save().

138  {
139  if ( $this->verify() != 0 ) return;
140  if ( $this->ad_id==-1 )
141  {
142  /* please adapt */
143  $sql="insert into amortissement.amortissement_detail(ad_percentage
144  ,ad_year
145  ,ad_amount
146  ,a_id
147  ) values ($1
148  ,$2
149  ,$3
150  ,$4
151  ) returning ad_id";
152 
153  $this->ad_id=$this->cn->get_value(
154  $sql,
155  array( $this->ad_percentage
156  ,$this->ad_year
157  ,$this->ad_amount
158  ,$this->a_id
159  )
160  );
161  }
162  else
163  {
164  $sql="insert into amortissement.amortissement_detail(ad_percentage
165  ,ad_year
166  ,ad_amount
167  ,a_id
168  ,ad_id) values ($1
169  ,$2
170  ,$3
171  ,$4
172  ,$5
173  ) returning ad_id";
174 
175  $this->ad_id=$this->cn->get_value(
176  $sql,
177  array( $this->ad_percentage
178  ,$this->ad_year
179  ,$this->ad_amount
180  ,$this->a_id
181  ,$this->ad_id)
182  );
183 
184  }
185 
186  }
$sql
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
Amortissement_Detail_Sql::load ( )

load a object

Returns
0 on success -1 the object is not found

Definition at line 211 of file class_amortissement_detail_sql.php.

References $key, $res, and $sql.

Referenced by __construct().

212  {
213 
214  $sql="select ad_percentage
215  ,ad_year
216  ,ad_amount
217  ,a_id
218  from amortissement.amortissement_detail where ad_id=$1";
219  /* please adapt */
220  $res=$this->cn->get_array(
221  $sql,
222  array($this->ad_id)
223  );
224 
225  if ( count($res) == 0 )
226  {
227  /* Initialize an empty object */
228  foreach ($this->variable as $key=>$value) $this->$key='';
229 
230  return -1;
231  }
232  foreach ($res[0] as $idx=>$value)
233  {
234  $this->$idx=$value;
235  }
236  return 0;
237  }
$key
$res
$sql
Amortissement_Detail_Sql::save ( )

Definition at line 102 of file class_amortissement_detail_sql.php.

References insert(), and update().

103  {
104  /* please adapt */
105  if ( $this->ad_id == -1 )
106  $this->insert();
107  else
108  $this->update();
109  }
Amortissement_Detail_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 118 of file class_amortissement_detail_sql.php.

References $array, and $sql.

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

Definition at line 73 of file class_amortissement_detail_sql.php.

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

Unit test for the class.

Definition at line 247 of file class_amortissement_detail_sql.php.

248  {
249 
250  }
Amortissement_Detail_Sql::update ( )

Definition at line 188 of file class_amortissement_detail_sql.php.

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

Referenced by save().

189  {
190  if ( $this->verify() != 0 ) return;
191  /* please adapt */
192  $sql=" update amortissement.amortissement_detail set ad_percentage = $1
193  ,ad_year = $2
194  ,ad_amount = $3
195  ,a_id = $4
196  where ad_id= $5";
197  $res=$this->cn->exec_sql(
198  $sql,
199  array($this->ad_percentage
200  ,$this->ad_year
201  ,$this->ad_amount
202  ,$this->a_id
203  ,$this->ad_id)
204  );
205 
206  }
$res
$sql
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
Amortissement_Detail_Sql::verify ( )

Definition at line 87 of file class_amortissement_detail_sql.php.

References a_id.

Referenced by insert(), and update().

88  {
89  // Verify that the elt we want to add is correct
90  /* verify only the datatype */
91  if ( settype($this->ad_percentage,'float') == false )
92  throw new Exception('DATATYPE ad_percentage $this->ad_percentage non numerique');
93  if ( settype($this->ad_year,'float') == false )
94  throw new Exception('DATATYPE ad_year $this->ad_year non numerique');
95  if ( settype($this->ad_amount,'float') == false )
96  throw new Exception('DATATYPE ad_amount $this->ad_amount non numerique');
97  if ( settype($this->a_id,'float') == false )
98  throw new Exception('DATATYPE a_id $this->a_id non numerique');
99 
100 
101  }
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_Detail_Sql::$variable
protected
Initial value:
=array("ad_id"=>"ad_id","ad_percentage"=>"ad_percentage"
,"ad_year"=>"ad_year"
,"ad_amount"=>"ad_amount"
,"a_id"=>"a_id"
)

Definition at line 40 of file class_amortissement_detail_sql.php.


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