noalyss
Version-6.7.2
|
Public Member Functions | |
__construct (&$p_cn, $p_id=-1) | |
delete () | |
from_array ($p_array) | |
Transform an array into object. | |
get_info () | |
get_object ($p_ret, $idx) | |
getp ($p_string) | |
insert () | |
load () | |
next ($ret, $i) | |
get_seek return the next object, the return of the query must have all the column of the object | |
save () | |
seek ($cond='', $p_array=null) | |
retrieve array of object thanks a condition | |
setp ($p_string, $p_value) | |
update () | |
verify () |
Definition at line 73 of file class_phpcompta_sql.php.
Phpcompta_SQL::__construct | ( | &$ | p_cn, |
$ | p_id = -1 |
||
) |
Reimplemented in Profile_sql, Default_Menu_SQL, and Tag_SQL.
Definition at line 76 of file class_phpcompta_sql.php.
Definition at line 153 of file class_phpcompta_sql.php.
References $sql, cn, sql_string(), and table.
{ $pk=$this->primary_key; $sql = " delete from " . $this->table . " where " . $this->primary_key . "=" . sql_string($this->$pk); $this->cn->exec_sql($sql); }
Phpcompta_SQL::from_array | ( | $ | p_array | ) |
Definition at line 222 of file class_phpcompta_sql.php.
{ return var_export($this, true); }
Phpcompta_SQL::get_object | ( | $ | p_ret, |
$ | idx | ||
) |
Phpcompta_SQL::getp | ( | $ | p_string | ) |
Definition at line 120 of file class_phpcompta_sql.php.
References $array, $idx, $sep, $sql, $value, cn, name, table, type, and verify().
Referenced by save().
{ $this->verify(); $sql = "insert into " . $this->table . " ( "; $sep = ""; $par = ""; $idx = 1; $array = array(); foreach ($this->name as $key=>$value) { if (isset($this->default[$value]) && $this->default[$value] == "auto" && $this->$value ==null ) continue; if ( $value==$this->primary_key && $this->$value == -1 ) continue; $sql.=$sep.$value; switch ($this->type[$value]) { case "date": if ($this->date_format=="") throw new Exception('Format Date invalide'); $par .=$sep. 'to_date($' . $idx . ",'" . $this->date_format . "')" ; break; default: $par .= $sep."$" . $idx ; } $array[] = $this->$value; $sep = ","; $idx++; } $sql.=") values (" . $par . ") returning " . $this->primary_key; $pk=$this->primary_key; $this->$pk = $this->cn->get_value($sql, $array); }
Definition at line 190 of file class_phpcompta_sql.php.
References $result, $sep, $sql, $value, cn, name, and type.
Referenced by __construct().
{ $sql = " select "; $sep="";$par=""; foreach ($this->name as $key) { switch ($this->type[$key]) { case "date": $sql .= $sep.'to_char(' . $key . ",'" . $this->date_format . "') as ".$key ; break; default: $sql.=$sep.$key ; } $sep = ","; } $pk=$this->primary_key; $sql.=" from ".$this->table; $sql.=" where " . $this->primary_key . " = " . $this->$pk; $result = $this->cn->get_array($sql); if ($this->cn->count() == 0 ) { $this->$pk=-1; return ; } foreach ($result[0] as $key=>$value) { $this->$key=$value; } }
Phpcompta_SQL::next | ( | $ | ret, |
$ | i | ||
) |
get_seek return the next object, the return of the query must have all the column of the object
$p_ret | is the return value of an exec_sql |
$idx | is the index |
Definition at line 276 of file class_phpcompta_sql.php.
References $array, $ret, cn, and from_array().
Referenced by get_object().
{ $array=$this->cn->fetch_array($ret,$i); return $this->from_array($array); }
Phpcompta_SQL::seek | ( | $ | cond = '' , |
$ | p_array = null |
||
) |
retrieve array of object thanks a condition
$cond | condition (where clause) (optional by default all the rows are fetched) you can use this parameter for the order or subselect |
$p_array | array for the SQL stmt |
Definition at line 262 of file class_phpcompta_sql.php.
Phpcompta_SQL::setp | ( | $ | p_string, |
$ | p_value | ||
) |
Definition at line 160 of file class_phpcompta_sql.php.
References $array, $idx, $sep, $sql, $value, cn, name, table, type, and verify().
Referenced by save().
{ $this->verify(); $pk=$this->primary_key; $sql = "update " . $this->table . " "; $sep = ""; $idx = 1; $array = array(); $set=" set "; foreach ($this->name as $key=>$value) { if (isset($this->default[$value]) && $this->default[$value] == "auto" ) continue; switch ($this->type[$value]) { case "date": $par =$value. '=to_date($' . $idx . ",'" . $this->date_format . "')" ; break; default: $par = $value."= $" . $idx ; } $sql.=$sep." $set " . $par ; $array[] = $this->$value; $sep = ",";$set="";$idx++; } $sql.=" where " . $this->primary_key . " =" . $this->$pk; $this->cn->exec_sql($sql, $array); }