|
noalyss
Version-6.7.2
|
Public Member Functions | |
| __construct (&$p_cn, $p_id=-1) | |
| collect_objects ($cond='', $p_array=null) | |
| return an array of objects. | |
| count ($p_where="", $p_array=null) | |
| 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 () | |
| Insert or update : if the row already exists, update otherwise insert. | |
| seek ($cond='', $p_array=null) | |
| retrieve array of object thanks a condition | |
| setp ($p_string, $p_value) | |
| update () | |
| verify () | |
Definition at line 72 of file class_noalyss_sql.php.
| Noalyss_SQL::__construct | ( | &$ | p_cn, |
| $ | p_id = -1 |
||
| ) |
Reimplemented in Anc_Key_Detail_SQL, Anc_Key_Ledger_SQL, Profile_sql, Profile_Menu_sql, Default_Menu_SQL, and Tag_SQL.
Definition at line 75 of file class_noalyss_sql.php.
| Noalyss_SQL::collect_objects | ( | $ | cond = '', |
| $ | p_array = null |
||
| ) |
return an array of objects.
Do not use this function if they are too many objects, it takes a lot of memory, and could slow down your application.
| $cond | condition, order... |
| $p_array | array to use for a condition |
Definition at line 312 of file class_noalyss_sql.php.
References $max, $p_array, $ret, next(), Database\num_row(), and seek().
| Noalyss_SQL::count | ( | $ | p_where = "", |
| $ | p_array = null |
||
| ) |
Definition at line 327 of file class_noalyss_sql.php.
References $count, $p_array, and cn.
Referenced by Stock_Goods\input(), Profile_Menu\listing_profile(), and Stock_Goods\take_last_inventory().
| Noalyss_SQL::from_array | ( | $ | p_array | ) |
Definition at line 229 of file class_noalyss_sql.php.
{
return var_export($this, true);
}
| Noalyss_SQL::get_object | ( | $ | p_ret, |
| $ | idx | ||
| ) |
| Noalyss_SQL::getp | ( | $ | p_string | ) |
Definition at line 123 of file class_noalyss_sql.php.
References $array, $idx, $key, $sep, $sql, $value, cn, name, 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 196 of file class_noalyss_sql.php.
References $key, $result, $sep, $sql, $value, cn, name, and type.
Referenced by __construct().
{
$sql=" select ";
$sep="";
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." = $1";
$result=$this->cn->get_array($sql,array ($this->$pk));
if ($this->cn->count()==0)
{
$this->$pk=-1;
return;
}
foreach ($result[0] as $key=> $value)
{
$this->$key=$value;
}
}
| Noalyss_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 291 of file class_noalyss_sql.php.
References $array, $ret, cn, and from_array().
Referenced by collect_objects(), and get_object().
{
$array=$this->cn->fetch_array($ret, $i);
return $this->from_array($array);
}
Insert or update : if the row already exists, update otherwise insert.
Definition at line 93 of file class_noalyss_sql.php.
| Noalyss_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 276 of file class_noalyss_sql.php.
References $p_array, $ret, $sql, and cn.
Referenced by collect_objects().
| Noalyss_SQL::setp | ( | $ | p_string, |
| $ | p_value | ||
| ) |
Definition at line 165 of file class_noalyss_sql.php.
References $array, $idx, $key, $sep, $sql, $value, cn, name, 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++;
}
$array[]=$this->$pk;
$sql.=" where ".$this->primary_key." = $".$idx;
$this->cn->exec_sql($sql, $array);
}