Plugins  LAST
 All Data Structures Files Functions Variables Pages
Public Member Functions
sql_impdol Class Reference
Inheritance diagram for sql_impdol:
Inheritance graph
Collaboration diagram for sql_impdol:
Collaboration graph

Public Member Functions

 __construct ($p_cn, $p_id=-1)
 
 getp ($p_string)
 
 setp ($p_string, $p_value)
 
 insert ()
 
 delete ()
 
 update ()
 
 load ()
 
 get_info ()
 
 verify ()
 
 from_array ($p_array)
 
 next ($ret, $i)
 

Detailed Description

Definition at line 20 of file class_sql_impdol.php.

Constructor & Destructor Documentation

sql_impdol::__construct (   $p_cn,
  $p_id = -1 
)

Definition at line 23 of file class_sql_impdol.php.

References $key, load(), and name.

24  {
25  $this->cn = $p_cn;
26  $pk=$this->primary_key;
27  $this->$pk= $p_id;
28 
29  if ($p_id == -1)
30  {
31  /* Initialize an empty object */
32  foreach ($this->name as $key )
33  {
34  $this->$key= null;
35  }
36  $this->$pk= $p_id;
37  }
38  else
39  {
40  /* load it */
41  $this->load();
42  }
43  }
$key
$categorie_appel name

Member Function Documentation

sql_impdol::delete ( )

Definition at line 99 of file class_sql_impdol.php.

References $sql, and table.

100  {
101  $pk=$this->primary_key;
102  $sql = " delete from " . $this->table . " where " . $this->primary_key . "=" . sql_string($this->$pk);
103  $this->cn->exec_sql($sql);
104  }
$categorie_appel table
$sql
sql_impdol::from_array (   $p_array)

Definition at line 180 of file class_sql_impdol.php.

References $key, and name.

Referenced by next().

181  {
182  foreach ($this->name as $key=>$value)
183  {
184  if ( isset ($p_array[$value]))
185  {
186  $this->$value=$p_array[$value];
187  }
188  }
189  }
$key
$categorie_appel name
sql_impdol::get_info ( )

Definition at line 168 of file class_sql_impdol.php.

169  {
170  return var_export($this, true);
171  }
sql_impdol::getp (   $p_string)

Definition at line 45 of file class_sql_impdol.php.

References name.

46  {
47  if (array_key_exists( $p_string,$this->name))
48  {
49  $idx = $this->name[$p_string];
50  return $this->$idx;
51  }
52  else
53  throw new Exception(__FILE__ . ":" . __LINE__ . $p_string . 'Erreur attribut inexistant '.$p_string);
54  }
$categorie_appel name
sql_impdol::insert ( )

Definition at line 67 of file class_sql_impdol.php.

References $array, $key, $sql, name, table, and verify().

68  {
69  $this->verify();
70  $sql = "insert into " . $this->table . " ( ";
71  $sep = "";
72  $par = "";
73  $idx = 1;
74  $array = array();
75  foreach ($this->name as $key=>$value)
76  {
77  if (isset($this->default[$value]) && $this->default[$value] == "auto" && $this->$value ==null )
78  continue;
79  if ( $value==$this->primary_key && $this->$value == -1 ) continue;
80  $sql.=$sep.$value;
81  switch ($this->type[$value])
82  {
83  case "date":
84  $par .=$sep. 'to_date($' . $idx . ",'" . $this->date_format . "')" ;
85  break;
86  default:
87  $par .= $sep."$" . $idx ;
88  }
89 
90  $array[] = $this->$value;
91  $sep = ",";
92  $idx++;
93  }
94  $sql.=") values (" . $par . ") returning " . $this->primary_key;
95  $pk=$this->primary_key;
96  $this->$pk = $this->cn->get_value($sql, $array);
97  }
if(isset($_POST['remove'])) $array
$key
$categorie_appel table
$categorie_appel name
$sql
sql_impdol::load ( )

Definition at line 136 of file class_sql_impdol.php.

References $key, $sql, and name.

Referenced by __construct().

137  {
138  $sql = " select ";
139  $sep="";$par="";
140 
141  foreach ($this->name as $key)
142  {
143 
144  switch ($this->type[$key])
145  {
146  case "date":
147  $sql .= $sep.'to_char(' . $key . ",'" . $this->date_format . "') as ".$key ;
148  break;
149  default:
150  $sql.=$sep.$key ;
151  }
152  $sep = ",";
153  }
154  $pk=$this->primary_key;
155  $sql.=" from ".$this->table;
156  $sql.=" where " . $this->primary_key . " = " . $this->$pk;
157  $result = $this->cn->get_array($sql);
158  if ($this->cn->count() == 0 ) {
159  $this->$pk=-1;
160  return;
161  }
162 
163  foreach ($result[0] as $key=>$value) {
164  $this->$key=$value;
165  }
166  }
$key
$categorie_appel name
$sql
sql_impdol::next (   $ret,
  $i 
)

Definition at line 190 of file class_sql_impdol.php.

References $array, $cn, $ret, and from_array().

190  {
191  global $cn;
192  $array=$this->cn->fetch_array($ret,$i);
193  $this->from_array($array);
194  }
$ret
from_array($p_array)
if(isset($_POST['remove'])) $array
global $cn
sql_impdol::setp (   $p_string,
  $p_value 
)

Definition at line 56 of file class_sql_impdol.php.

References name.

57  {
58  if (array_key_exists( $p_string,$this->name))
59  {
60  $idx = $this->name[$p_string];
61  $this->$idx = $p_value;
62  }
63  else
64  throw new Exception(__FILE__ . ":" . __LINE__ . $p_string . 'Erreur attribut inexistant '.$p_string);
65  }
$categorie_appel name
sql_impdol::update ( )

Definition at line 106 of file class_sql_impdol.php.

References $array, $key, $sql, name, table, and verify().

107  {
108  $this->verify();
109  $pk=$this->primary_key;
110  $sql = "update " . $this->table . " ";
111  $sep = "";
112  $idx = 1;
113  $array = array();
114  $set=" set ";
115  foreach ($this->name as $key=>$value)
116  {
117  if (isset($this->default[$value]) && $this->default[$value] == "auto" )
118  continue;
119  switch ($this->type[$value])
120  {
121  case "date":
122  $par =$value. '=to_date($' . $idx . ",'" . $this->date_format . "')" ;
123  break;
124  default:
125  $par = $value."= $" . $idx ;
126  }
127  $sql.=$sep." $set " . $par ;
128  $array[] = $this->$value;
129  $sep = ",";$set="";$idx++;
130  }
131  $sql.=" where " . $this->primary_key . " =" . $this->$pk;
132  $this->cn->exec_sql($sql, $array);
133 
134  }
if(isset($_POST['remove'])) $array
$key
$categorie_appel table
$categorie_appel name
$sql
sql_impdol::verify ( )

Definition at line 173 of file class_sql_impdol.php.

References $key, and name.

Referenced by insert(), and update().

174  {
175  foreach($this->name as $key){
176  if ( trim($this->$key)=='') $this->$key=null;
177  }
178  return 0;
179  }
$key
$categorie_appel name

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