56 define(
'MDB2_AUTOQUERY_INSERT', 1);
57 define(
'MDB2_AUTOQUERY_UPDATE', 2);
58 define(
'MDB2_AUTOQUERY_DELETE', 3);
59 define(
'MDB2_AUTOQUERY_SELECT', 4);
103 return $db->prepare(
$query, $types, $result_types);
132 $where =
false, $types = null, $result_class =
true, $result_types =
MDB2_PREPARE_MANIP)
134 $fields_values = (array)$fields_values;
136 if (is_array($result_types)) {
137 $keys = array_keys($result_types);
138 } elseif (!empty($fields_values)) {
139 $keys = $fields_values;
144 $keys = array_keys($fields_values);
146 $params = array_values($fields_values);
147 if (empty($params)) {
155 $result =& $db->query(
$query, $result_types, $result_class);
157 $result = $db->exec(
$query);
160 $stmt = $this->
autoPrepare($table, $keys, $mode, $where, $types, $result_types);
164 $result =& $stmt->execute($params, $result_class);
201 if ($db->options[
'quote_identifier']) {
202 $table = $db->quoteIdentifier($table);
205 if (!empty($table_fields) && $db->options[
'quote_identifier']) {
206 foreach ($table_fields as $key => $field) {
207 $table_fields[$key] = $db->quoteIdentifier($field);
211 if ($where !==
false && !is_null($where)) {
212 if (is_array($where)) {
213 $where = implode(
' AND ', $where);
215 $where =
' WHERE '.$where;
220 if (empty($table_fields)) {
222 'Insert requires table fields', __FUNCTION__);
224 $cols = implode(
', ', $table_fields);
225 $values =
'?'.str_repeat(
', ?', (count($table_fields) - 1));
226 return 'INSERT INTO '.$table.
' ('.$cols.
') VALUES ('.$values.
')';
229 if (empty($table_fields)) {
231 'Update requires table fields', __FUNCTION__);
233 $set = implode(
' = ?, ', $table_fields).
' = ?';
234 $sql =
'UPDATE '.$table.
' SET '.$set.$where;
238 $sql =
'DELETE FROM '.$table.$where;
242 $cols = !empty($table_fields) ? implode(
', ', $table_fields) :
'*';
243 $sql =
'SELECT '.$cols.
' FROM '.$table.$where;
248 'Non existant mode', __FUNCTION__);
268 $result_wrap_class =
false)
275 $result = $db->setLimit($limit, $offset);
279 $result =& $db->query(
$query, $types, $result_class, $result_wrap_class);
304 settype($params,
'array');
305 if (empty($params)) {
314 $result = $stmt->execute($params);
341 $param_types = null, $colnum = 0)
348 settype($params,
'array');
349 settype(
$type,
'array');
350 if (empty($params)) {
359 $result = $stmt->execute($params);
364 $one = $result->fetchOne($colnum);
395 settype($params,
'array');
396 if (empty($params)) {
397 return $db->queryRow(
$query, $types, $fetchmode);
400 $stmt = $db->prepare(
$query, $param_types, $types);
405 $result = $stmt->execute($params);
410 $row = $result->fetchRow($fetchmode);
434 $param_types = null, $colnum = 0)
441 settype($params,
'array');
442 settype(
$type,
'array');
443 if (empty($params)) {
452 $result = $stmt->execute($params);
457 $col = $result->fetchCol($colnum);
490 $rekey =
false, $force_array =
false, $group =
false)
497 settype($params,
'array');
498 if (empty($params)) {
499 return $db->queryAll(
$query, $types, $fetchmode, $rekey, $force_array, $group);
502 $stmt = $db->prepare(
$query, $param_types, $types);
507 $result = $stmt->execute($params);
512 $all = $result->fetchAll($fetchmode, $rekey, $force_array, $group);
602 settype($params,
'array');
603 if (empty($params)) {
604 return $db->queryAll(
$query, $types, $fetchmode,
true, $force_array, $group);
607 $stmt = $db->prepare(
$query, $param_types, $types);
612 $result = $stmt->execute($params);
617 $all = $result->fetchAll($fetchmode,
true, $force_array, $group);
643 for ($i = 0, $j = count($params); $i < $j; $i++) {
644 $result = $stmt->execute($params[$i]);
667 function getBeforeID($table, $field = null, $ondemand =
true, $quote =
true)
674 if ($db->supports(
'auto_increment') !==
true) {
675 $seq = $table.(empty($field) ?
'' :
'_'.$field);
676 $id = $db->nextID($seq, $ondemand);
680 return $db->quote($id,
'integer');
707 if ($db->supports(
'auto_increment') !==
true) {
710 return $db->lastInsertID($table, $field);