ILIAS
Release_4_4_x_branch Revision 61816
|
Public Member Functions | |
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. | |
& | 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. | |
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. | |
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. | |
getRow ($query, $types=null, $params=array(), $param_types=null, $fetchmode=MDB2_FETCHMODE_DEFAULT) | |
Fetch the first row of data returned from a query. | |
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. | |
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. | |
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 as the key. | |
executeMultiple (&$stmt, $params=null) | |
This function does several execute() calls on the same statement handle. | |
getBeforeID ($table, $field=null, $ondemand=true, $quote=true) | |
Returns the next free id of a sequence if the RDBMS does not support auto increment. | |
getAfterID ($id, $table, $field=null) | |
Returns the autoincrement ID if supported or $id. | |
Public Member Functions inherited from MDB2_Module_Common | |
__construct ($db_index) | |
Constructor. | |
MDB2_Module_Common ($db_index) | |
PHP 4 Constructor. | |
& | getDBInstance () |
Get the instance of MDB2 associated with the module instance. |
Additional Inherited Members | |
Data Fields inherited from MDB2_Module_Common | |
$db_index |
Definition at line 68 of file Extended.php.
& MDB2_Extended::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.
string | name of the table |
array | assoc ($key=>$value) where $key is a field name and $value its value |
int | type of query to build MDB2_AUTOQUERY_INSERT MDB2_AUTOQUERY_UPDATE MDB2_AUTOQUERY_DELETE MDB2_AUTOQUERY_SELECT |
string | (in case of update and delete queries, this string will be put after the sql WHERE statement) |
array | that contains the types of the placeholders |
string | which specifies which result class to use |
mixed | array that contains the types of the columns in the result set or MDB2_PREPARE_RESULT, if set to MDB2_PREPARE_MANIP the query is handled as a manipulation query |
Definition at line 131 of file Extended.php.
References $query, $result, autoPrepare(), buildManipSQL(), MDB2_Module_Common\getDBInstance(), PEAR\isError(), and MDB2_AUTOQUERY_SELECT.
MDB2_Extended::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.
string | table |
array | the fields names |
int | type of query to build MDB2_AUTOQUERY_INSERT MDB2_AUTOQUERY_UPDATE MDB2_AUTOQUERY_DELETE MDB2_AUTOQUERY_SELECT |
string | (in case of update and delete queries, this string will be put after the sql WHERE statement) |
array | that contains the types of the placeholders |
mixed | array that contains the types of the columns in the result set or MDB2_PREPARE_RESULT, if set to MDB2_PREPARE_MANIP the query is handled as a manipulation query |
Definition at line 92 of file Extended.php.
References $query, buildManipSQL(), MDB2_Module_Common\getDBInstance(), and PEAR\isError().
Referenced by autoExecute().
MDB2_Extended::buildManipSQL | ( | $table, | |
$table_fields, | |||
$mode, | |||
$where = false |
|||
) |
Make automaticaly an sql query for prepare()
Example : buildManipSQL('table_sql', array('field1', 'field2', 'field3'), MDB2_AUTOQUERY_INSERT) will return the string : INSERT INTO table_sql (field1,field2,field3) VALUES (?,?,?) NB : - This belongs more to a SQL Builder class, but this is a simple facility
string | name of the table |
ordered | array containing the fields names |
int | type of query to build MDB2_AUTOQUERY_INSERT MDB2_AUTOQUERY_UPDATE MDB2_AUTOQUERY_DELETE MDB2_AUTOQUERY_SELECT |
string | (in case of update and delete queries, this string will be put after the sql WHERE statement) |
Definition at line 194 of file Extended.php.
References MDB2_Module_Common\getDBInstance(), PEAR\isError(), MDB2_AUTOQUERY_DELETE, MDB2_AUTOQUERY_INSERT, MDB2_AUTOQUERY_SELECT, MDB2_AUTOQUERY_UPDATE, MDB2_ERROR_NEED_MORE_DATA, and MDB2_ERROR_SYNTAX.
Referenced by autoExecute(), and autoPrepare().
MDB2_Extended::execParam | ( | $query, | |
$params = array() , |
|||
$param_types = null |
|||
) |
Execute a parameterized DML statement.
string | the SQL query |
array | if supplied, prepare/execute will be used with this array as execute parameters |
array | that contains the types of the values defined in $params |
Definition at line 297 of file Extended.php.
References $query, $result, MDB2_Module_Common\getDBInstance(), PEAR\isError(), and MDB2_PREPARE_MANIP.
MDB2_Extended::executeMultiple | ( | & | $stmt, |
$params = null |
|||
) |
This function does several execute() calls on the same statement handle.
$params must be an array indexed numerically from 0, one execute call is done for every 'row' in the array.
If an error occurs during execute(), executeMultiple() does not execute the unfinished rows, but rather returns that error.
resource | query handle from prepare() |
array | numeric array containing the data to insert into the query |
Definition at line 641 of file Extended.php.
References $result, PEAR\isError(), and MDB2_OK.
MDB2_Extended::getAfterID | ( | $id, | |
$table, | |||
$field = null |
|||
) |
Returns the autoincrement ID if supported or $id.
mixed | value as returned by getBeforeId() |
string | name of the table into which a new row was inserted |
string | name of the field into which a new row was inserted |
Definition at line 700 of file Extended.php.
References MDB2_Module_Common\getDBInstance(), and PEAR\isError().
MDB2_Extended::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.
string | the SQL query | |
array | that contains the types of the columns in the result set | |
array | if supplied, prepare/execute will be used with this array as execute parameters | |
array | that contains the types of the values defined in $params | |
int | the fetch mode to use | |
bool | if set to true, the $all will have the first column as its first dimension | |
bool | $force_array | used only when the query returns exactly two columns. If true, the values of the returned array will be one-element arrays instead of scalars. |
bool | $group | if true, the values of the returned array is wrapped in another array. If the same key value (in the first column) repeats itself, the values will be appended to this array instead of overwriting the existing values. |
Definition at line 488 of file Extended.php.
References $query, $result, MDB2_Module_Common\getDBInstance(), PEAR\isError(), and MDB2\isResultCommon().
MDB2_Extended::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 as the key.
If the result set contains more than two columns, the value will be an array of the values from column 2-n. If the result set contains only two columns, the returned value will be a scalar with the value of the second column (unless forced to an array with the $force_array parameter). A MDB2 error code is returned on errors. If the result set contains fewer than two columns, a MDB2_ERROR_TRUNCATED error is returned.
For example, if the table 'mytable' contains:
ID TEXT DATE -------------------------------- 1 'one' 944679408 2 'two' 944679408 3 'three' 944679408
Then the call getAssoc('SELECT id,text FROM mytable') returns:
array( '1' => 'one', '2' => 'two', '3' => 'three', )
...while the call getAssoc('SELECT id,text,date FROM mytable') returns:
array( '1' => array('one', '944679408'), '2' => array('two', '944679408'), '3' => array('three', '944679408') )
If the more than one row occurs with the same value in the first column, the last row overwrites all previous ones by default. Use the $group parameter if you don't want to overwrite like this. Example:
getAssoc('SELECT category,id,name FROM mytable', null, null MDB2_FETCHMODE_ASSOC, false, true) returns: array( '1' => array(array('id' => '4', 'name' => 'number four'), array('id' => '6', 'name' => 'number six') ), '9' => array(array('id' => '4', 'name' => 'number four'), array('id' => '6', 'name' => 'number six') ) )
Keep in mind that database functions in PHP usually return string values for results regardless of the database's internal type.
string | the SQL query | |
array | that contains the types of the columns in the result set | |
array | if supplied, prepare/execute will be used with this array as execute parameters | |
array | that contains the types of the values defined in $params | |
bool | $force_array | used only when the query returns exactly two columns. If TRUE, the values of the returned array will be one-element arrays instead of scalars. |
bool | $group | if TRUE, the values of the returned array is wrapped in another array. If the same key value (in the first column) repeats itself, the values will be appended to this array instead of overwriting the existing values. |
Definition at line 594 of file Extended.php.
References $query, $result, MDB2_Module_Common\getDBInstance(), PEAR\isError(), and MDB2\isResultCommon().
MDB2_Extended::getBeforeID | ( | $table, | |
$field = null , |
|||
$ondemand = true , |
|||
$quote = true |
|||
) |
Returns the next free id of a sequence if the RDBMS does not support auto increment.
string | name of the table into which a new row was inserted |
string | name of the field into which a new row was inserted |
bool | when true the sequence is automatic created, if it not exists |
bool | if the returned value should be quoted |
Definition at line 667 of file Extended.php.
References MDB2_Module_Common\getDBInstance(), and PEAR\isError().
MDB2_Extended::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.
string | the SQL query |
string | that contains the type of the column in the result set |
array | if supplied, prepare/execute will be used with this array as execute parameters |
array | that contains the types of the values defined in $params |
int|string | which column to return |
Definition at line 433 of file Extended.php.
References $query, $result, MDB2_Module_Common\getDBInstance(), PEAR\isError(), and MDB2\isResultCommon().
MDB2_Extended::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.
Takes care of doing the query and freeing the results when finished.
string | the SQL query |
string | that contains the type of the column in the result set |
array | if supplied, prepare/execute will be used with this array as execute parameters |
array | that contains the types of the values defined in $params |
int|string | which column to return |
Definition at line 340 of file Extended.php.
References $query, $result, MDB2_Module_Common\getDBInstance(), PEAR\isError(), and MDB2\isResultCommon().
MDB2_Extended::getRow | ( | $query, | |
$types = null , |
|||
$params = array() , |
|||
$param_types = null , |
|||
$fetchmode = MDB2_FETCHMODE_DEFAULT |
|||
) |
Fetch the first row of data returned from a query.
Takes care of doing the query and freeing the results when finished.
string | the SQL query |
array | that contains the types of the columns in the result set |
array | if supplied, prepare/execute will be used with this array as execute parameters |
array | that contains the types of the values defined in $params |
int | the fetch mode to use |
Definition at line 387 of file Extended.php.
References $query, $result, $row, MDB2_Module_Common\getDBInstance(), PEAR\isError(), and MDB2\isResultCommon().
& MDB2_Extended::limitQuery | ( | $query, | |
$types, | |||
$limit, | |||
$offset = 0 , |
|||
$result_class = true , |
|||
$result_wrap_class = false |
|||
) |
Generates a limited query.
string | query |
array | that contains the types of the columns in the result set |
integer | the numbers of rows to fetch |
integer | the row to start to fetching |
string | which specifies which result class to use |
mixed | string which specifies which class to wrap results in |
Definition at line 267 of file Extended.php.
References $query, $result, MDB2_Module_Common\getDBInstance(), and PEAR\isError().