88#[AllowDynamicProperties]
95 parent::__construct($p_cn,
$p_id);
103 $sql=
"insert into ".$this->table.
" ( ";
110 if (isset($this->
default[
$value])&&$this->
default[$value]==
"auto"&&$this->$value==
null)
113 if (
$value==$this->primary_key && $this->$value==-1 && isset($this->
default[$value]) )
116 switch ($this->
type[$value])
119 if ($this->date_format==
"")
120 throw new Exception(
'Format Date invalide');
121 $par .=
$sep.
'to_timestamp($'.
$idx.
",'".$this->date_format.
"')";
134 $this->$pk=$returning;
137 public function delete()
140 $sql=
" delete from ".$this->table.
" where ".$this->primary_key.
"= $1";
141 $this->
cn->exec_sql(
$sql,array($this->$pk));
154 $sql=
"update ".$this->table.
" set {$column_expr} where {$this->primary_key} = $2";
163 $sql=
"update ".$this->table.
" ";
169 if (isset($this->
default[
$value])&&$this->
default[$value]==
"auto")
171 switch ($this->
type[$value])
174 $par=
$value.
'=to_timestamp($'.
$idx.
",'".$this->date_format.
"')";
186 $sql.=
" where ".$this->primary_key.
" = $".
$idx;
197 if (trim($this->$pk??
"")===
"" || $this->$pk===
null) {
203 if ($this->
cn->count()==0)
227 $sql=
"select * from ".$this->table.
" $cond";
240 $count=$this->
cn->get_value(
"select count(*) from $this->table ".$p_where,
$p_array);
249 $count=$this->
cn->get_value(
"select count(*) from ".$this->
table.
" where ".$this->primary_key.
"=$1",array($this->$pk));
261 foreach ($this->
name as $key) {
262 switch ($this->
type[$key])
265 $sql .=
$sep.
'to_char('.$key.
",'".$this->date_format.
"') as ".$key;
273 $sql.=
" from ".$this->table;
275 $sql.=
" where ".$this->primary_key.
" = $1";
306 if (!isset($a_array[
$i][$p_key_col]))
308 throw new Exception(
"col not found ".$p_key_col);
310 $key=$a_array[
$i][$p_key_col];
311 if ( isset ($a_result[$key]) ){
312 throw new Exception (
"duplicate found col : $key");
314 $a_result[$key]=$a_array[
$i];
317 catch (Exception $exc)
319 echo $exc->getMessage();
record_log($p_message)
Record an error message into the log file of the server.
this an abstract class , all the SQL class, like noalyss_sql (table), Acc_Plan_SQL (based on a SQL no...
$primary_key
Array of logical and real name.
static fetch_all($ret)
wrapper for the function pg_fetch_all
Interface : this wrapper is used to created easily a wrapper to a table (ORM) You must create a class...
count($p_where="", $p_array=null)
return the number of count in the table corresponding to the where condition
build_query()
Build the SQL select statement for querying the object and returns it.
load()
Load the current row return false if not found.
seek($cond='', $p_array=null)
retrieve array of object thanks a condition
exist()
Count the number of record with the id ,.
__construct($p_cn, $p_id=-1)
get_all_to_array($p_key_col, $p_cond="", $p_array=NULL)
Get all the row and use the p_key_code are the key value of array.
column_update($column_expr, $value)
update the value of a column with an expression for $value for the current record