noalyss Version-9
Public Member Functions
V_Currency_Last_Value_SQL Class Reference

class_currency_history_sql.php More...

+ Inheritance diagram for V_Currency_Last_Value_SQL:
+ Collaboration diagram for V_Currency_Last_Value_SQL:

Public Member Functions

 __construct (Database $p_cn, $p_id=-1)
 
 count ($p_where="", $p_array=null)
 
 delete ()
 
 exist ()
 Count the number of record with the id ,. More...
 
 insert ()
 
 load ()
 Load the current row return false if not found. More...
 
 seek ($cond='', $p_array=null)
 retrieve array of object thanks a condition More...
 
 update ()
 
- Public Member Functions inherited from Data_SQL
 __construct (DatabaseCore $p_cn, $p_id=-1)
 
 __toString ()
 
 collect_objects ($cond='', $p_array=null)
 return an array of objects. More...
 
 count ($p_where="", $p_array=null)
 
 delete ()
 
 exist ()
 Count the number of record with the id ,. More...
 
 from_array ($p_array)
 Transform an array into object. More...
 
 get ($p_string)
 get the value thanks the colum name and not the alias (name). More...
 
 get_cn ()
 
 get_info ()
 
 get_name ()
 
 get_object ($p_ret, $idx)
 
 get_pk_value ()
 
 get_primary_key ()
 
 get_type ()
 
 getp ($p_string)
 set the value thanks the alias name instead of the colum name More...
 
 insert ()
 
 load ()
 Load the current row return false if not found. More...
 
 next ($ret, $i)
 get_seek return the next object, the return of the query must have all the column of the object More...
 
 save ()
 Insert or update : if the row already exists, update otherwise insert. More...
 
 seek ($cond='', $p_array=null)
 retrieve array of object thanks a condition More...
 
 set ($p_string, $p_value)
 set the value thanks the colum name and not the alias (name) More...
 
 set_cn ($cn)
 
 set_name ($name)
 
 set_pk_value ($p_value)
 
 set_primary_key ($primary_key)
 
 set_type ($type)
 
 setp ($p_string, $p_value)
 set the value thanks the alias name instead of the colum name More...
 
 to_array ($prefix="")
 Turn an object (row) into an array, and the key could be prefixed with $prefix. More...
 
 to_row ($p_array)
 turns a row fetched from the DB into a SQL object in updating all his attribute More...
 
 update ()
 
 verify ()
 

Additional Inherited Members

- Data Fields inherited from Data_SQL
 $cn
 
 $date_format
 Type of the data. More...
 
 $default
 defaullt date format More...
 
 $name
 Database connection. More...
 
 $primary_key
 Array of logical and real name. More...
 
 $table
 
 $type
 Column name of the primary key. More...
 

Detailed Description

class_currency_history_sql.php

abstract of the view public.v_currency_last_value

Examples
test_currency_mtable.php.

Definition at line 36 of file v_currency_last_value_sql.class.php.

Constructor & Destructor Documentation

◆ __construct()

V_Currency_Last_Value_SQL::__construct ( Database  $p_cn,
  $p_id = -1 
)

Definition at line 39 of file v_currency_last_value_sql.class.php.

40 {
41 $this->table="public.v_currency_last_value";
42 $this->primary_key="currency_id";
43 /*
44 * List of columns
45 */
46 $this->name=array(
47 "currency_id"=>"currency_id"
48 , "cr_name"=>"cr_name"
49 , "cr_code_iso"=>"cr_code_iso"
50 , "currency_history_id"=>"currency_history_id"
51 , "ch_value"=>"ch_value"
52 , "str_from"=>"str_from"
53 );
54 /*
55 * Type of columns
56 */
57 $this->type=array(
58 "currency_id"=>"numeric"
59 , "cr_name"=>"text"
60 , "cr_code_iso"=>"text"
61 , "currency_history_id"=>"numeric"
62 , "ch_value"=>"numeric"
63 , "str_from"=>"text"
64 );
65
66
67 $this->default=array(
68 "currency_id"=>"auto"
69 );
70
71 $this->date_format="DD.MM.YYYY";
72 parent::__construct($p_cn, $p_id);
73 }
$from_poste name
$input_from type
Definition: balance.inc.php:65
$all table

References $p_id, name, table, and type.

Member Function Documentation

◆ count()

V_Currency_Last_Value_SQL::count (   $p_where = "",
  $p_array = null 
)

Reimplemented from Data_SQL.

Definition at line 75 of file v_currency_last_value_sql.class.php.

76 {
77 $count=$this->cn->get_value("select count(*) from $this->table ".$p_where, $p_array);
78 return $count;
79 }
$input_from cn
Definition: balance.inc.php:66
$count

References $count, $p_array, and cn.

◆ delete()

V_Currency_Last_Value_SQL::delete ( )

Reimplemented from Data_SQL.

Definition at line 81 of file v_currency_last_value_sql.class.php.

82 {
83 /* check if currency is used */
84 $is_used = $this->cn->get_value("select count(*) from jrn where currency_id=$1",[$this->currency_id]);
85
86 /* if not used , we can delete it */
87 if ( $is_used <> 0 ) { throw new Exception (_("Devise utilisée")); }
88
89 // We cannot delete EUR
90 if ( $this->currency_id == -1 ) {
91 throw new Exception(_("EUR ne peut pas être effacé"));
92 }
93 $this->cn->exec_sql("delete from currency_history where currency_id=$1",[$this->currency_id]);
94 $this->cn->exec_sql("delete from currency where id=$1",[$this->currency_id]);
95
96 }

References cn.

◆ exist()

V_Currency_Last_Value_SQL::exist ( )

Count the number of record with the id ,.

Returns
integer 0 doesn't exist , 1 exists

Reimplemented from Data_SQL.

Definition at line 98 of file v_currency_last_value_sql.class.php.

99 {
101 $count=$this->cn->get_value("select count(*) from ".$this->table." where ".$this->primary_key."=$1",
102 array($this->$pk));
103 return $count;
104 }
$primary_key
Array of logical and real name.

References $count, Data_SQL\$primary_key, cn, and table.

◆ insert()

V_Currency_Last_Value_SQL::insert ( )

Reimplemented from Data_SQL.

Definition at line 106 of file v_currency_last_value_sql.class.php.

107 {
108
109 }

◆ load()

V_Currency_Last_Value_SQL::load ( )

Load the current row return false if not found.

if ( $this->get_limit_fiche_qcode() != 0 )
{
$sql=sprintf($this->sql," limit ".$this->get_limit_fiche_qcode());
} else
{
$sql=sprintf($this->sql," ");
}
$result=$this->cn->get_array($sql. " where id=$1",array ($this->$pk));
if ($this->cn->count()==0)
{
$this->$pk=-1;
return false;
}
foreach ($result[0] as $key=> $value)
{
$this->$key=$value;
}
return true;
Returns
bool

Reimplemented from Data_SQL.

Definition at line 111 of file v_currency_last_value_sql.class.php.

111 :bool
112 {
113 $sql=" select ";
114 $sep="";
115 foreach ($this->name as $key)
116 {
117 switch ($this->type[$key])
118 {
119 case "date":
120 $sql.=$sep.'to_char('.$key.",'".$this->date_format."') as ".$key;
121 break;
122 default:
123 $sql.=$sep.$key;
124 }
125 $sep=",";
126 }
128 $sql.=" from ".$this->table;
129
130 $sql.=" where ".$this->primary_key." = $1";
131
132 $result=$this->cn->get_array($sql, array($this->$pk));
133 if ($this->cn->count()==0)
134 {
135 $this->$pk=-1;
136 return false;
137 }
138
139 foreach ($result[0] as $key=> $value)
140 {
141 $this->$key=$value;
142 }
143 return true;
144 }

References Data_SQL\$primary_key, $result, $sep, $sql, $value, cn, name, and type.

◆ seek()

V_Currency_Last_Value_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

Reimplemented from Data_SQL.

Definition at line 146 of file v_currency_last_value_sql.class.php.

147 {
148 $sql="select * from ".$this->table." $cond";
149 $ret=$this->cn->exec_sql($sql, $p_array);
150 return $ret;
151 }

References $p_array, $ret, $sql, and cn.

◆ update()

V_Currency_Last_Value_SQL::update ( )

Reimplemented from Data_SQL.

Definition at line 153 of file v_currency_last_value_sql.class.php.

154 {
155
156 }

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