95#[AllowDynamicProperties]
110 $ret.=
"[ $name => {$this->$name} ]";
113 $ret.=
"| type ".print_r($this->
type,
true);
114 $ret.=
"| default ".print_r($this->
default,
true);
115 $ret.=
"| primary key ".$this->primary_key;
116 $ret.=
"| date_format ".$this->date_format;
128 throw new Exception (__FILE__.
" $this->table Cannot instantiate");
133 foreach ($this->
name as $key)
135 if ( in_array($key,[
'name',
'type',
'format_date',
'cn',
'date_format',
'default'] ) ) {
136 throw new Exception (
'DATASQL-94 invalid column name'.$key);
143 if ( empty($this->date_format) ) $this->date_format=
"DD.MM.YYYY";
161 public function get($p_string)
163 if (array_key_exists($p_string, $this->
type)) {
164 return $this->$p_string;
167 throw new Exception(__FILE__.
":".__LINE__.$p_string.
'Erreur attribut inexistant '.$p_string);
174 public function set($p_string, $p_value)
176 if (array_key_exists($p_string, $this->
type)) {
177 $this->$p_string=$p_value;
180 throw new Exception(__FILE__.
":".__LINE__.$p_string.
'Erreur attribut inexistant '.$p_string);
187 public function getp($p_string)
189 if (array_key_exists($p_string, $this->
name)) {
194 throw new Exception(__FILE__.
":".__LINE__.$p_string.
'Erreur attribut inexistant '.$p_string);
201 public function setp($p_string, $p_value)
203 if (array_key_exists($p_string, $this->
name)) {
205 $this->
$idx=$p_value;
208 throw new Exception(__FILE__.
":".__LINE__.$p_string.
'Erreur attribut inexistant '.$p_string);
213 abstract function delete();
259 return var_export($this,
true);
267 foreach ($this->
name as $key)
366 throw new Exception(_(
"Erreur : exec_sql attend un array"));
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.
to_array($prefix="")
Turn an object (row) into an array, and the key could be prefixed with $prefix.
exist()
Count the number of record with the id ,.
__construct(DatabaseCore $p_cn, $p_id=-1)
collect_objects($cond='', $p_array=null)
return an array of objects.
setp($p_string, $p_value)
set the value thanks the alias name instead of the colum name
count($p_where="", $p_array=null)
load()
Load the current row return false if not found.
to_row($p_array)
turns a row fetched from the DB into a SQL object in updating all his attribute
$date_format
Type of the data.
seek($cond='', $p_array=null)
retrieve array of object thanks a condition
from_array($p_array)
Transform an array into object.
set_primary_key($primary_key)
next($ret, $i)
get_seek return the next object, the return of the query must have all the column of the object
getp($p_string)
set the value thanks the alias name instead of the colum name
$name
Database connection.
save()
Insert or update : if the row already exists, update otherwise insert.
$default
defaullt date format
$type
Column name of the primary key.
This class allow you to connect to the postgresql database, execute sql, retrieve data.
static num_row($ret)
wrapper for the function pg_num_rows