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);
201 if ($db->options[
'quote_identifier']) {
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);
341 $param_types = null, $colnum = 0)
349 settype(
$type,
'array');
364 $one =
$result->fetchOne($colnum);
397 return $db->queryRow(
$query, $types, $fetchmode);
400 $stmt = $db->prepare(
$query, $param_types, $types);
434 $param_types = null, $colnum = 0)
442 settype(
$type,
'array');
457 $col =
$result->fetchCol($colnum);
490 $rekey =
false, $force_array =
false, $group =
false)
499 return $db->queryAll(
$query, $types, $fetchmode, $rekey, $force_array, $group);
502 $stmt = $db->prepare(
$query, $param_types, $types);
512 $all =
$result->fetchAll($fetchmode, $rekey, $force_array, $group);
604 return $db->queryAll(
$query, $types, $fetchmode,
true, $force_array, $group);
607 $stmt = $db->prepare(
$query, $param_types, $types);
617 $all =
$result->fetchAll($fetchmode,
true, $force_array, $group);
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);
const MDB2_OK(!class_exists('PEAR'))
The method mapErrorCode in each MDB2_dbtype implementation maps native error codes to one of these...
getAfterID($id, $table, $field=null)
Returns the autoincrement ID if supported or $id.
getAssoc($query, $types=null, $params=array(), $param_types=null, $fetchmode=MDB2_FETCHMODE_DEFAULT, $force_array=false, $group=false)
Fetch the entire result set of a query and return it as an associative array using the first column a...
const MDB2_FETCHMODE_DEFAULT
This is a special constant that tells MDB2 the user hasn't specified any particular get mode...
executeMultiple(&$stmt, $params=null)
This function does several execute() calls on the same statement handle.
if(!array_key_exists('StateId', $_REQUEST)) $id
getCol($query, $type=null, $params=array(), $param_types=null, $colnum=0)
Fetch a single column from a result set and return it as an indexed array.
getOne($query, $type=null, $params=array(), $param_types=null, $colnum=0)
Fetch the first column of the first row of data returned from a query.
& autoExecute($table, $fields_values, $mode=MDB2_AUTOQUERY_INSERT, $where=false, $types=null, $result_class=true, $result_types=MDB2_PREPARE_MANIP)
Generate an insert, update or delete query and call prepare() and execute() on it.
const MDB2_AUTOQUERY_SELECT
const MDB2_AUTOQUERY_DELETE
const MDB2_PREPARE_MANIP
These are just helper constants to more verbosely express parameters to prepare() ...
const MDB2_ERROR_NEED_MORE_DATA
getRow($query, $types=null, $params=array(), $param_types=null, $fetchmode=MDB2_FETCHMODE_DEFAULT)
Fetch the first row of data returned from a query.
isResultCommon($value)
Tell whether a value is a MDB2 result implementing the common interface.
const MDB2_AUTOQUERY_UPDATE
Create styles array
The data for the language used.
buildManipSQL($table, $table_fields, $mode, $where=false)
Make automaticaly an sql query for prepare()
& limitQuery($query, $types, $limit, $offset=0, $result_class=true, $result_wrap_class=false)
Generates a limited query.
execParam($query, $params=array(), $param_types=null)
Execute a parameterized DML statement.
& getDBInstance()
Get the instance of MDB2 associated with the module instance.
getAll($query, $types=null, $params=array(), $param_types=null, $fetchmode=MDB2_FETCHMODE_DEFAULT, $rekey=false, $force_array=false, $group=false)
Fetch all the rows returned from a query.
getBeforeID($table, $field=null, $ondemand=true, $quote=true)
Returns the next free id of a sequence if the RDBMS does not support auto increment.
autoPrepare($table, $table_fields, $mode=MDB2_AUTOQUERY_INSERT, $where=false, $types=null, $result_types=MDB2_PREPARE_MANIP)
Generate an insert, update or delete query and call prepare() on it.
if(empty($password)) $table
const MDB2_AUTOQUERY_INSERT
Used by autoPrepare()
isError($data, $code=null)
Tell whether a value is a PEAR error.