ILIAS
release_5-3 Revision v5.3.23-19-g915713cf615
|
Database Wrapper. More...
Public Member Functions | |||
setDBUser ($a_user) | |||
Set database user. More... | |||
getDBUser () | |||
Get database user. More... | |||
setDBPort ($a_port) | |||
Set database port. More... | |||
getDBPort () | |||
Get database port. More... | |||
setDBHost ($a_host) | |||
Set database host. More... | |||
getDBHost () | |||
Get database host. More... | |||
setDBPassword ($a_password) | |||
Set database password. More... | |||
getDBPassword () | |||
Get database password. More... | |||
setDBName ($a_name) | |||
Set database name. More... | |||
getDBName () | |||
Get database name. More... | |||
getDSN () | |||
Get DSN. More... | |||
getDBVersion () | |||
Get DB version. More... | |||
getDBType () | |||
Get DSN. More... | |||
enableResultBuffering ($a_status) | |||
En/disable result buffering. More... | |||
initFromIniFile ($tmpClientIniFile=null) | |||
Init db parameters from ini file. More... | |||
connect ($a_return_false_for_error=false) | |||
Open the connection. More... | |||
doConnect () | |||
Standard way to connect to db. More... | |||
disconnect () | |||
Disconnect. More... | |||
getHostDSN () | |||
Should return a valid value, if host connections are possible (connectHost) to create a new database from scratch. More... | |||
connectHost () | |||
Sets up a host connection only (no specific database used). More... | |||
supportsFulltext () | |||
supportsSlave () | |||
Supports slave. More... | |||
supports ($feature) | |||
supportsTransactions () | |||
useSlave ($a_val=true) | |||
Use slave. More... | |||
handleError ($a_res, $a_info="", $a_level="") | |||
Handle MDB2 Errors. More... | |||
raisePearError ($a_message, $a_level="") | |||
Raise an error. More... | |||
createDatabase ($a_name, $a_charset="utf8", $a_collation="") | |||
Create database. More... | |||
createTable ( $a_name, $a_definition_array, $a_drop_table=false, $a_ignore_erros=false) | |||
Create a new table in the database. More... | |||
dropTable ($a_name, $a_error_if_not_existing=true) | |||
Drop a table. More... | |||
alterTable ($a_name, $a_changes) | |||
Alter a table in the database This method is DEPRECATED, see http://www.ilias.de/docu/goto.php?target=pg_25354_42&client_id=docu PLEASE USE THE SPECIALIZED METHODS OF THIS CLASS TO CHANGE THE DB SCHEMA. More... | |||
addTableColumn ($a_table, $a_column, $a_attributes) | |||
Add table column Use this only on aleady "abstracted" tables. More... | |||
dropTableColumn ($a_table, $a_column) | |||
Drop table column Use this only on aleady "abstracted" tables. More... | |||
modifyTableColumn ($a_table, $a_column, $a_attributes) | |||
Modify a table column Use this only on aleady "abstracted" tables. More... | |||
renameTableColumn ($a_table, $a_column, $a_new_column) | |||
Rename a table column Use this only on aleady "abstracted" tables. More... | |||
renameTable ($a_name, $a_new_name) | |||
Rename a table. More... | |||
addPrimaryKey ($a_table, $a_fields) | |||
Add a primary key to a table. More... | |||
getPrimaryKeyIdentifier () | |||
Primary key identifier. More... | |||
dropPrimaryKey ($a_table) | |||
Drop a primary key from a table. More... | |||
addFulltextIndex ($a_table, $a_fields, $a_name="in") | |||
Add fulltext index. More... | |||
isFulltextIndex ($a_table, $a_name) | |||
Is index a fulltext index? More... | |||
indexExistsByFields ($a_table, $a_fields) | |||
Check if index exists. More... | |||
dropIndexByFields ($a_table, $a_fields) | |||
Drop index by field(s) More... | |||
dropIndex ($a_table, $a_name="in") | |||
Drop an index from a table. More... | |||
addUniqueConstraint ($a_table, $a_fields, $a_name="con") | |||
Add a unique constraint to a table. More... | |||
dropUniqueConstraint ($a_table, $a_name="con") | |||
Drop a constraint from a table. More... | |||
dropUniqueConstraintByFields ($a_table, $a_fields) | |||
Drop constraint by field(s) More... | |||
createSequence ($a_table_name, $a_start=1) | |||
Create a sequence for a table. More... | |||
dropSequence ($a_table_name) | |||
Drop a sequence for a table. More... | |||
checkTableName ($a_name) | |||
Check whether a table name is valid. More... | |||
checkTableColumns ($a_cols) | |||
Check table columns definition. More... | |||
checkColumn ($a_col, $a_def) | |||
Check column definition. More... | |||
checkColumnDefinition ($a_def, $a_modify_mode=false) | |||
Check whether a column definition is valid. More... | |||
checkColumnName ($a_name) | |||
Check whether a column name is valid. More... | |||
checkIndexName ($a_name) | |||
Check whether an index name is valid. More... | |||
getAllowedAttributes () | |||
constraintName ($a_table, $a_constraint) | |||
Determine contraint name by table name and constraint name. More... | |||
query ($sql, $a_handle_error=true) | |||
Query. More... | |||
queryF ($a_query, $a_types, $a_values) | |||
Formatted query (for SELECTS). More... | |||
manipulateF ($a_query, $a_types, $a_values) | |||
Formatted manupulate (for DELETE, UPDATE, INSERT). More... | |||
logStatement ($sql) | |||
Helper function, should usually not be called. More... | |||
setLimit ($a_limit, $a_offset=0) | |||
Set limit and offset for a query. More... | |||
nextId ($a_table_name) | |||
Get next ID for an index. More... | |||
manipulate ($sql) | |||
Data manipulation. More... | |||
prepare ($a_query, $a_types=null, $a_result_types=null) | |||
Prepare a query (SELECT) statement to be used with execute. More... | |||
prepareManip ($a_query, $a_types=null) | |||
Prepare a data manipulation statement to be used with execute. More... | |||
execute ($a_stmt, $a_data=null) | |||
Execute a query statement prepared by either prepare() or prepareManip() More... | |||
executeMultiple ($a_stmt, $a_data) | |||
Execute a query statement prepared by either prepare() or prepareManip() with multiple data arrays. More... | |||
insert ($a_table, $a_columns) | |||
Convenient method for standard insert statements, example field array: More... | |||
update ($a_table, $a_columns, $a_where) | |||
Convenient method for standard update statements, example field array: More... | |||
replace ($a_table, $a_pk_columns, $a_other_columns) | |||
Replace into method. More... | |||
fetchAssoc ($a_set) | |||
Fetch row as associative array from result set. More... | |||
free ($a_st) | |||
Free a statement / result set. More... | |||
fetchObject ($a_set) | |||
Fetch row as object from result set. More... | |||
numRows ($a_set) | |||
Fetch row as associative array from result set. More... | |||
in ($a_field, $a_values, $negate=false, $a_type="") | |||
Get abstract in-clause for given array. More... | |||
addTypesToArray ($a_arr, $a_type, $a_cnt) | |||
Adds a type x times to an array. More... | |||
now () | |||
now() More... | |||
concat (array $a_values, $a_allow_null=true) | |||
Abstraction of SQL function CONCAT. More... | |||
substr ($a_exp, $a_pos=1, $a_len=-1) | |||
Substring. More... | |||
upper ($a_exp) | |||
Upper. More... | |||
lower ($a_exp) | |||
Upper. More... | |||
locate ($a_needle, $a_string, $a_start_pos=1) | |||
Create locate string. More... | |||
like ($a_col, $a_type, $a_value="?", $case_insensitive=true) | |||
Like. More... | |||
equals ($a_col, $a_value, $a_type, $a_empty_or_null=false) | |||
Use this only on text fields. More... | |||
equalsNot ($a_col, $a_value, $a_type, $a_empty_or_null=false) | |||
Use this only on text fields. More... | |||
fromUnixtime ($a_expr, $a_to_text=true) | |||
fromUnixtime (makes timestamp out of unix timestamp) More... | |||
unixTimestamp () | |||
Unix timestamp. More... | |||
tableExists ($a_table) | |||
Check, whether a given table exists. More... | |||
tableColumnExists ($a_table, $a_column_name) | |||
Checks for the existence of a table column. More... | |||
uniqueConstraintExists ($a_table, array $a_fields) | |||
Checks if a unique constraint exists based on the fields of the unique constraint (not the name) More... | |||
listTables () | |||
Get all tables. More... | |||
sequenceExists ($a_sequence) | |||
Check, whether a given sequence exists. More... | |||
listSequences () | |||
Get all sequences. More... | |||
quote ($a_query, $a_type=null) | |||
Wrapper for quote method. More... | |||
quoteIdentifier ($a_identifier, $check_option=false) | |||
Quote table and field names. More... | |||
beginTransaction () | |||
Begin Transaction. More... | |||
commit () | |||
Commit a transaction. More... | |||
rollback () | |||
Rollback a transaction. More... | |||
lockTables ($a_tables) | |||
Abstraction of lock table. More... | |||
unlockTables () | |||
Unlock tables locked by previous lock table calls. More... | |||
autoExecute ($a_tablename, $a_fields, $a_mode=MDB2_AUTOQUERY_INSERT, $a_where=false) | |||
Wrapper for Pear autoExecute. More... | |||
getLastInsertId () | |||
Get last insert id. More... | |||
getOne ($sql) | |||
getOne. More... | |||
getRow ($sql, $mode=ilDBConstants::FETCHMODE_OBJECT) | |||
getRow. More... | |||
setSubType ($a_value) | |||
Set sub type. More... | |||
getSubType () | |||
Get sub type. More... | |||
migrateAllTablesToEngine ($engine=ilDBConstants::MYSQL_ENGINE_INNODB) | |||
supportsEngineMigration () | |||
getSequenceName ($table_name) | |||
buildAtomQuery () | |||
sanitizeMB4StringIfNotSupported ($query) | |||
| |||
doesCollationSupportMB4Strings () | |||
cast ($a_field_name, $a_dest_type) | |||
Public Member Functions inherited from PEAR | |||
__construct ($error_class=null) | |||
Constructor. More... | |||
_PEAR () | |||
Destructor (the emulated type of...). More... | |||
registerShutdownFunc ($func, $args=array()) | |||
Use this function to register a shutdown method for static classes. More... | |||
isError ($data, $code=null) | |||
Tell whether a value is a PEAR error. More... | |||
expectError ($code=' *') | |||
This method is used to tell which errors you expect to get. More... | |||
popExpect () | |||
This method pops one element off the expected error codes stack. More... | |||
_checkDelExpect ($error_code) | |||
This method checks unsets an error code if available. More... | |||
delExpect ($error_code) | |||
This method deletes all occurences of the specified element from the expected error codes stack. More... | |||
& | raiseError ($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false) | ||
This method is a wrapper that returns an instance of the configured error class with this object's default error handling applied. More... | |||
& | throwError ($message=null, $code=null, $userinfo=null) | ||
Simpler form of raiseError with fewer options. More... | |||
staticPushErrorHandling ($mode, $options=null) | |||
staticPopErrorHandling () | |||
pushErrorHandling ($mode, $options=null) | |||
Push a new error handler on top of the error handler options stack. More... | |||
popErrorHandling () | |||
Pop the last error handler used. More... | |||
loadExtension ($ext) | |||
OS independant PHP extension load. More... | |||
Public Member Functions inherited from ilDBInterface | |||
query ($query) | |||
Run a (read-only) Query on the database. More... | |||
fetchAll ($query_result, $fetch_mode=ilDBConstants::FETCHMODE_ASSOC) | |||
addIndex ($table_name, $fields, $index_name='', $fulltext=false) | |||
substr ($a_exp) | |||
loadModule ($module) | |||
dropFulltextIndex ($a_table, $a_name) | |||
setStorageEngine ($storage_engine) | |||
getStorageEngine () | |||
groupConcat ($a_field_name, $a_seperator=",", $a_order=null) | |||
Static Public Member Functions | |
static | getReservedWords () |
Get reserved words. More... | |
static | isDbError ($a_res) |
Check error. More... | |
static | isReservedWord ($a_word) |
Checks whether a word is a reserved word in one of the supported databases. More... | |
Static Public Member Functions inherited from PEAR | |
static & | getStaticProperty ($class, $var) |
If you have a class that's mostly/entirely static, and you need static properties, you can use this method to simulate them. More... | |
static | setErrorHandling ($mode=null, $options=null) |
Sets how errors generated by this object should be handled. More... | |
Data Fields | |
const | LOCK_WRITE = 1 |
const | LOCK_READ = 2 |
$error_class | |
$db | |
$result | |
$allowed_attributes | |
$sub_type | |
Data Fields inherited from PEAR | |
$_debug = false | |
$_default_error_mode = null | |
$_default_error_options = null | |
$_default_error_handler = '' | |
$_error_class = 'PEAR_Error' | |
$_expected_errors = array() | |
Protected Member Functions | |
initConnection () | |
Initialize the database connection. More... | |
initHostConnection () | |
Initialize the host connection (no specific database) More... | |
loadMDB2Extensions () | |
load additional mdb2 extensions and set their constants More... | |
getCreateTableOptions () | |
Get options for the create table statement. More... | |
Database Wrapper.
this class should extend PEAR::DB, add error Management in case of a db-error in any database query the ilDB-class raises an error
Definition at line 29 of file class.ilDB.php.
ilDB::addFulltextIndex | ( | $a_table, | |
$a_fields, | |||
$a_name = "in" |
|||
) |
Add fulltext index.
Implements ilDBInterface.
Definition at line 929 of file class.ilDB.php.
Referenced by dropPrimaryKey().
ilDB::addPrimaryKey | ( | $a_table, | |
$a_fields | |||
) |
Add a primary key to a table.
string | table name |
array | fields for primary key |
string | key name |
Implements ilDBInterface.
Definition at line 839 of file class.ilDB.php.
References $r, array, constraintName(), getPrimaryKeyIdentifier(), and handleError().
ilDB::addTableColumn | ( | $a_table, | |
$a_column, | |||
$a_attributes | |||
) |
Add table column Use this only on aleady "abstracted" tables.
string | table name |
string | column name |
array | attributes array("length" => 10, "default" => "t") |
Implements ilDBInterface.
Definition at line 637 of file class.ilDB.php.
References $r, array, checkColumnDefinition(), checkColumnName(), handleError(), and raisePearError().
ilDB::addTypesToArray | ( | $a_arr, | |
$a_type, | |||
$a_cnt | |||
) |
Adds a type x times to an array.
Definition at line 1798 of file class.ilDB.php.
References $a_type, and array.
ilDB::addUniqueConstraint | ( | $a_table, | |
$a_fields, | |||
$a_name = "con" |
|||
) |
Add a unique constraint to a table.
string | table name |
array | fields being unique |
string | index name |
Definition at line 1015 of file class.ilDB.php.
References $r, array, checkIndexName(), constraintName(), handleError(), and raisePearError().
ilDB::alterTable | ( | $a_name, | |
$a_changes | |||
) |
Alter a table in the database This method is DEPRECATED, see http://www.ilias.de/docu/goto.php?target=pg_25354_42&client_id=docu PLEASE USE THE SPECIALIZED METHODS OF THIS CLASS TO CHANGE THE DB SCHEMA.
Definition at line 617 of file class.ilDB.php.
References $r, array, and handleError().
ilDB::autoExecute | ( | $a_tablename, | |
$a_fields, | |||
$a_mode = MDB2_AUTOQUERY_INSERT , |
|||
$a_where = false |
|||
) |
Wrapper for Pear autoExecute.
string | tablename |
array | fields values |
int | MDB2_AUTOQUERY_INSERT or MDB2_AUTOQUERY_UPDATE |
string | where condition (e.g. "obj_id = '7' AND ref_id = '5'") |
Definition at line 2233 of file class.ilDB.php.
References $res, and handleError().
ilDB::beginTransaction | ( | ) |
Begin Transaction.
Please note that we currently do not use savepoints.
Implements ilDBInterface.
Definition at line 2173 of file class.ilDB.php.
References $res, handleError(), and raisePearError().
ilDB::buildAtomQuery | ( | ) |
ilDB::cast | ( | $a_field_name, | |
$a_dest_type | |||
) |
Implements ilDBInterface.
Definition at line 2413 of file class.ilDB.php.
ilDB::checkColumn | ( | $a_col, | |
$a_def | |||
) |
Check column definition.
Definition at line 1164 of file class.ilDB.php.
References checkColumnDefinition(), and checkColumnName().
Referenced by checkTableColumns().
ilDB::checkColumnDefinition | ( | $a_def, | |
$a_modify_mode = false |
|||
) |
Check whether a column definition is valid.
array | definition array |
Definition at line 1182 of file class.ilDB.php.
References $allowed_attributes, and array.
Referenced by addTableColumn(), checkColumn(), and modifyTableColumn().
ilDB::checkColumnName | ( | $a_name | ) |
Check whether a column name is valid.
string | $a_name |
Definition at line 1246 of file class.ilDB.php.
References isReservedWord(), and substr().
Referenced by addTableColumn(), checkColumn(), and renameTableColumn().
ilDB::checkIndexName | ( | $a_name | ) |
Check whether an index name is valid.
string | $a_name |
Definition at line 1276 of file class.ilDB.php.
References isReservedWord().
Referenced by addUniqueConstraint(), and dropPrimaryKey().
ilDB::checkTableColumns | ( | $a_cols | ) |
Check table columns definition.
array | definition array |
Definition at line 1150 of file class.ilDB.php.
References $def, and checkColumn().
Referenced by createTable().
ilDB::checkTableName | ( | $a_name | ) |
Check whether a table name is valid.
string | $a_name |
Implements ilDBInterface.
Definition at line 1120 of file class.ilDB.php.
References isReservedWord(), and substr().
Referenced by createTable(), and renameTable().
ilDB::commit | ( | ) |
Commit a transaction.
Implements ilDBInterface.
Definition at line 2186 of file class.ilDB.php.
References $res, and handleError().
ilDB::concat | ( | array | $a_values, |
$a_allow_null = true |
|||
) |
Abstraction of SQL function CONCAT.
array | $a_values | array( array('title','text'), array('description','clob'), array('some text','text'); |
bool | $a_allow_null |
Implements ilDBInterface.
Definition at line 1830 of file class.ilDB.php.
ilDB::connect | ( | $a_return_false_for_error = false | ) |
Open the connection.
Implements ilDBInterface.
Definition at line 234 of file class.ilDB.php.
References array, doConnect(), getDSN(), handleError(), initConnection(), isDbError(), MDB2\isError(), loadMDB2Extensions(), MDB2_PORTABILITY_ALL, PEAR_ERROR_CALLBACK, raisePearError(), and PEAR\setErrorHandling().
ilDB::connectHost | ( | ) |
Sets up a host connection only (no specific database used).
This is optional during the setup procudure to create databases from scratch.
Definition at line 312 of file class.ilDB.php.
References array, MDB2\connect(), getHostDSN(), handleError(), initHostConnection(), isDbError(), MDB2\isError(), loadMDB2Extensions(), MDB2_PORTABILITY_EMPTY_TO_NULL, MDB2_PORTABILITY_FIX_CASE, PEAR_ERROR_CALLBACK, raisePearError(), and PEAR\setErrorHandling().
ilDB::constraintName | ( | $a_table, | |
$a_constraint | |||
) |
Determine contraint name by table name and constraint name.
In MySQL these are "unique" per table, but they must be "globally" unique in oracle. (so this one is overwritten there)
Implements ilDBInterface.
Definition at line 1306 of file class.ilDB.php.
Referenced by ilDBMySQL\addFulltextIndex(), addPrimaryKey(), addUniqueConstraint(), ilDBMySQL\dropFulltextIndex(), dropIndex(), dropPrimaryKey(), and dropUniqueConstraint().
ilDB::createDatabase | ( | $a_name, | |
$a_charset = "utf8" , |
|||
$a_collation = "" |
|||
) |
Create database.
Implements ilDBInterface.
Definition at line 500 of file class.ilDB.php.
References query().
ilDB::createSequence | ( | $a_table_name, | |
$a_start = 1 |
|||
) |
Create a sequence for a table.
Implements ilDBInterface.
Definition at line 1093 of file class.ilDB.php.
References $r, and handleError().
ilDB::createTable | ( | $a_name, | |
$a_definition_array, | |||
$a_drop_table = false , |
|||
$a_ignore_erros = false |
|||
) |
Create a new table in the database.
string | table name |
array | definition array: array("col1" => array("type" => "text", ...)) |
boolean | drop table automatically, if it already exists |
Implements ilDBInterface.
Definition at line 522 of file class.ilDB.php.
References $options, $r, checkTableColumns(), checkTableName(), dropTable(), getCreateTableOptions(), handleError(), and raisePearError().
ilDB::disconnect | ( | ) |
ilDB::doConnect | ( | ) |
Standard way to connect to db.
Definition at line 270 of file class.ilDB.php.
References array, MDB2\connect(), and getDSN().
Referenced by connect().
ilDB::doesCollationSupportMB4Strings | ( | ) |
Implements ilDBInterface.
Definition at line 2404 of file class.ilDB.php.
Referenced by sanitizeMB4StringIfNotSupported().
ilDB::dropIndex | ( | $a_table, | |
$a_name = "in" |
|||
) |
Drop an index from a table.
Note: The index must have been created using MDB2
string | table name |
string | index name |
Implements ilDBInterface.
Definition at line 995 of file class.ilDB.php.
References $r, constraintName(), ilDBInterface\dropFulltextIndex(), handleError(), and isFulltextIndex().
Referenced by dropIndexByFields().
ilDB::dropIndexByFields | ( | $a_table, | |
$a_fields | |||
) |
Drop index by field(s)
type | $a_table | |
type | $a_fields |
Implements ilDBInterface.
Definition at line 971 of file class.ilDB.php.
References $def, array, and dropIndex().
ilDB::dropPrimaryKey | ( | $a_table | ) |
Drop a primary key from a table.
string | table name |
string | key name |
Definition at line 874 of file class.ilDB.php.
References $r, addFulltextIndex(), ilDBInterface\addIndex(), array, checkIndexName(), constraintName(), getPrimaryKeyIdentifier(), handleError(), raisePearError(), and supportsFulltext().
ilDB::dropSequence | ( | $a_table_name | ) |
Drop a sequence for a table.
Implements ilDBInterface.
Definition at line 1106 of file class.ilDB.php.
References $r, and handleError().
ilDB::dropTable | ( | $a_name, | |
$a_error_if_not_existing = true |
|||
) |
Drop a table.
string | table name |
boolean | raise an error, if table not exists |
Implements ilDBInterface.
Definition at line 568 of file class.ilDB.php.
References $i, $r, getDBType(), handleError(), listTables(), and substr().
Referenced by createTable().
ilDB::dropTableColumn | ( | $a_table, | |
$a_column | |||
) |
Drop table column Use this only on aleady "abstracted" tables.
string | table name |
string | column name |
Implements ilDBInterface.
Definition at line 668 of file class.ilDB.php.
References $r, array, and handleError().
ilDB::dropUniqueConstraint | ( | $a_table, | |
$a_name = "con" |
|||
) |
Drop a constraint from a table.
Note: The constraint must have been created using MDB2
string | table name |
string | constraint name |
Definition at line 1046 of file class.ilDB.php.
References $r, constraintName(), and handleError().
Referenced by dropUniqueConstraintByFields().
ilDB::dropUniqueConstraintByFields | ( | $a_table, | |
$a_fields | |||
) |
Drop constraint by field(s)
string | table name |
array | fields array |
Definition at line 1065 of file class.ilDB.php.
References dropUniqueConstraint().
ilDB::enableResultBuffering | ( | $a_status | ) |
En/disable result buffering.
bool | $a_status |
Implements ilDBInterface.
Definition at line 202 of file class.ilDB.php.
ilDB::equals | ( | $a_col, | |
$a_value, | |||
$a_type, | |||
$a_empty_or_null = false |
|||
) |
Use this only on text fields.
Implements ilDBInterface.
Definition at line 1949 of file class.ilDB.php.
References $a_type, and quote().
ilDB::equalsNot | ( | $a_col, | |
$a_value, | |||
$a_type, | |||
$a_empty_or_null = false |
|||
) |
Use this only on text fields.
Definition at line 1961 of file class.ilDB.php.
References $a_type, and quote().
ilDB::execute | ( | $a_stmt, | |
$a_data = null |
|||
) |
Execute a query statement prepared by either prepare() or prepareManip()
object | Resource handle of the prepared query. |
array | Array of data (to be used for placeholders) |
Implements ilDBInterface.
Definition at line 1512 of file class.ilDB.php.
References $res, and handleError().
ilDB::executeMultiple | ( | $a_stmt, | |
$a_data | |||
) |
Execute a query statement prepared by either prepare() or prepareManip() with multiple data arrays.
object | Resource handle of the prepared query. |
array | Array of array of data (to be used for placeholders) |
Definition at line 1528 of file class.ilDB.php.
References $res, and handleError().
ilDB::fetchAssoc | ( | $a_set | ) |
Fetch row as associative array from result set.
mixed | result set |
Implements ilDBInterface.
Definition at line 1724 of file class.ilDB.php.
References ilDBConstants\FETCHMODE_ASSOC.
Referenced by assLongMenu\calculateReachedPoints(), assLongMenu\getCorrectAnswersForGap(), assLongMenu\getCorrectAnswersForQuestionSolution(), assLongMenu\getPointsForGap(), ilDBMySQL\isFulltextIndex(), assLongMenu\loadCorrectAnswerData(), assLongMenu\loadFromDb(), and ilTestArchiver\updateTestArchive().
ilDB::fetchObject | ( | $a_set | ) |
Fetch row as object from result set.
object | result set |
Implements ilDBInterface.
Definition at line 1742 of file class.ilDB.php.
References ilDBConstants\FETCHMODE_OBJECT.
ilDB::free | ( | $a_st | ) |
Free a statement / result set.
Implements ilDBInterface.
Definition at line 1732 of file class.ilDB.php.
Referenced by insert(), replace(), and update().
ilDB::fromUnixtime | ( | $a_expr, | |
$a_to_text = true |
|||
) |
fromUnixtime (makes timestamp out of unix timestamp)
string | expression |
boolean | typecasting to text y/n |
Definition at line 1980 of file class.ilDB.php.
ilDB::getAllowedAttributes | ( | ) |
Implements ilDBInterface.
Definition at line 1296 of file class.ilDB.php.
References $allowed_attributes.
|
protected |
Get options for the create table statement.
Definition at line 557 of file class.ilDB.php.
References array.
Referenced by createTable().
ilDB::getDBHost | ( | ) |
Get database host.
string | database host |
Definition at line 123 of file class.ilDB.php.
Referenced by ilDBOracle\getDSN(), ilDBPostgreSQL\getDSN(), and ilDBMySQL\getDSN().
ilDB::getDBName | ( | ) |
Get database name.
string | database name |
Definition at line 163 of file class.ilDB.php.
References getDSN().
Referenced by ilDBOracle\getDSN(), ilDBPostgreSQL\getDSN(), and ilDBMySQL\getDSN().
ilDB::getDBPassword | ( | ) |
Get database password.
string | database password |
Definition at line 143 of file class.ilDB.php.
Referenced by ilDBOracle\getDSN(), ilDBPostgreSQL\getDSN(), ilDBMySQL\getDSN(), and ilDBMySQL\getHostDSN().
ilDB::getDBPort | ( | ) |
Get database port.
string | database port |
Definition at line 103 of file class.ilDB.php.
Referenced by ilDBOracle\getDSN(), and ilDBMySQL\getDSN().
|
abstract |
Get DSN.
This must be overwritten in DBMS specific class.
Implements ilDBInterface.
Referenced by dropTable(), and getDBVersion().
ilDB::getDBUser | ( | ) |
Get database user.
string | database user |
Definition at line 83 of file class.ilDB.php.
Referenced by ilDBOracle\getDSN(), ilDBPostgreSQL\getDSN(), ilDBMySQL\getDSN(), and ilDBMySQL\getHostDSN().
ilDB::getDBVersion | ( | ) |
Get DB version.
Definition at line 176 of file class.ilDB.php.
References getDBType().
|
abstract |
Get DSN.
This must be overwritten in DBMS specific class.
Implements ilDBInterface.
Referenced by connect(), doConnect(), and getDBName().
ilDB::getHostDSN | ( | ) |
Should return a valid value, if host connections are possible (connectHost) to create a new database from scratch.
Definition at line 303 of file class.ilDB.php.
Referenced by connectHost().
ilDB::getLastInsertId | ( | ) |
Get last insert id.
Definition at line 2249 of file class.ilDB.php.
References $res, and MDB2\isError().
ilDB::getOne | ( | $sql | ) |
getOne.
DEPRECATED. Should not be used anymore.
this is the wrapper itself. Runs a query and returns the first column of the first row or in case of an error, jump to errorpage
string |
Definition at line 2267 of file class.ilDB.php.
References $r, ilDBConstants\FETCHMODE_ASSOC, handleError(), and MDB2\isError().
ilDB::getPrimaryKeyIdentifier | ( | ) |
Primary key identifier.
Implements ilDBInterface.
Definition at line 863 of file class.ilDB.php.
Referenced by addPrimaryKey(), and dropPrimaryKey().
|
static |
Get reserved words.
This must be overwritten in DBMS specific class. This is mainly used to check whether a new identifier can be problematic because it is a reserved word. So createTable / alterTable usually check these.
Implements ilDBInterface.
Definition at line 192 of file class.ilDB.php.
References array.
ilDB::getRow | ( | $sql, | |
$mode = ilDBConstants::FETCHMODE_OBJECT |
|||
) |
getRow.
DEPRECATED. Should not be used anymore
this is the wrapper itself. query a string, and return the resultobject, or in case of an error, jump to errorpage
string |
Definition at line 2290 of file class.ilDB.php.
References $data, $r, array, ilDBInterface\fetchAll(), ilDBConstants\FETCHMODE_ASSOC, handleError(), and query().
ilDB::getSequenceName | ( | $table_name | ) |
$table_name |
Implements ilDBInterface.
Definition at line 2364 of file class.ilDB.php.
ilDB::getSubType | ( | ) |
Get sub type.
Definition at line 2334 of file class.ilDB.php.
References $sub_type.
Referenced by ilDBMySQL\isMySQLi().
ilDB::handleError | ( | $a_res, | |
$a_info = "" , |
|||
$a_level = "" |
|||
) |
Handle MDB2 Errors.
mixed | result set or anything that is a MDB2::error if something went wrong |
Definition at line 423 of file class.ilDB.php.
References $ilLog, and MDB2\isError().
Referenced by addPrimaryKey(), addTableColumn(), addUniqueConstraint(), alterTable(), autoExecute(), beginTransaction(), commit(), connect(), connectHost(), createSequence(), createTable(), dropIndex(), ilDBOracle\dropPrimaryKey(), dropPrimaryKey(), dropSequence(), dropTable(), dropTableColumn(), dropUniqueConstraint(), execute(), executeMultiple(), getOne(), getRow(), insert(), manipulate(), modifyTableColumn(), nextId(), prepare(), prepareManip(), ilDBMySQL\query(), query(), renameTable(), renameTableColumn(), ilDBPostgreSQL\replace(), ilDBOracle\replace(), replace(), rollback(), and update().
ilDB::in | ( | $a_field, | |
$a_values, | |||
$negate = false , |
|||
$a_type = "" |
|||
) |
Get abstract in-clause for given array.
Returns an array "field_name IN (?,?,?,...)" depending on the size of the array
Example: $ids = array(10,12,18); $st = $ilDB->prepare("SELECT * FROM table ". "WHERE ".$ilDB->in("id", $ids), $ilDB->addTypesToArray($types, "integer", count($ids))); $set = $ilDB->execute($st, $ids);
Implements ilDBInterface.
Definition at line 1772 of file class.ilDB.php.
References $a_type, and quote().
ilDB::indexExistsByFields | ( | $a_table, | |
$a_fields | |||
) |
Check if index exists.
type | $a_table | |
type | $a_fields |
Implements ilDBInterface.
Definition at line 948 of file class.ilDB.php.
|
protected |
Initialize the database connection.
Definition at line 293 of file class.ilDB.php.
Referenced by connect().
ilDB::initFromIniFile | ( | $tmpClientIniFile = null | ) |
Init db parameters from ini file.
$tmpClientIniFile | overwrite global client ini file if is set to an object |
Implements ilDBInterface.
Definition at line 211 of file class.ilDB.php.
References setDBHost(), setDBName(), setDBPassword(), setDBPort(), and setDBUser().
|
protected |
Initialize the host connection (no specific database)
Definition at line 355 of file class.ilDB.php.
Referenced by connectHost().
ilDB::insert | ( | $a_table, | |
$a_columns | |||
) |
Convenient method for standard insert statements, example field array:
array("field1" => array("text", $name), "field2" => array("integer", $id))
Implements ilDBInterface.
Definition at line 1541 of file class.ilDB.php.
References $r, array, free(), handleError(), manipulateF(), and MDB2_PREPARE_MANIP.
Referenced by ilDBPostgreSQL\replace(), and ilDBOracle\replace().
|
static |
Check error.
Definition at line 488 of file class.ilDB.php.
References MDB2\isError().
Referenced by connect(), connectHost(), and loadMDB2Extensions().
ilDB::isFulltextIndex | ( | $a_table, | |
$a_name | |||
) |
Is index a fulltext index?
Implements ilDBInterface.
Definition at line 937 of file class.ilDB.php.
Referenced by dropIndex().
|
static |
Checks whether a word is a reserved word in one of the supported databases.
Implements ilDBInterface.
Definition at line 1315 of file class.ilDB.php.
References $DIC.
Referenced by checkColumnName(), checkIndexName(), checkTableName(), and ilDatabaseReservedWordsTest\testReservedMDB2().
ilDB::like | ( | $a_col, | |
$a_type, | |||
$a_value = "?" , |
|||
$case_insensitive = true |
|||
) |
Like.
string | column type; must be "text" or "clob" ("blob" added for lng_data) |
Implements ilDBInterface.
Definition at line 1923 of file class.ilDB.php.
References $a_type, array, quote(), and raisePearError().
ilDB::listSequences | ( | ) |
Get all sequences.
Implements ilDBInterface.
Definition at line 2113 of file class.ilDB.php.
References $r, and MDB2\isError().
Referenced by sequenceExists().
ilDB::listTables | ( | ) |
Get all tables.
Implements ilDBInterface.
Definition at line 2078 of file class.ilDB.php.
References $r, and MDB2\isError().
Referenced by dropTable(), and tableExists().
|
protected |
load additional mdb2 extensions and set their constants
protected
Definition at line 474 of file class.ilDB.php.
References isDbError(), MDB2_AUTOQUERY_DELETE, MDB2_AUTOQUERY_INSERT, MDB2_AUTOQUERY_SELECT, and MDB2_AUTOQUERY_UPDATE.
Referenced by connect(), and connectHost().
ilDB::locate | ( | $a_needle, | |
$a_string, | |||
$a_start_pos = 1 |
|||
) |
Create locate string.
string | $a_needle | |
string | $a_string | |
int | $a_start_pos | [optional] |
Implements ilDBInterface.
Definition at line 1905 of file class.ilDB.php.
|
abstract |
Abstraction of lock table.
array | table definitions |
Implements ilDBInterface.
Referenced by rollback().
ilDB::logStatement | ( | $sql | ) |
Helper function, should usually not be called.
Definition at line 1405 of file class.ilDB.php.
References $table, and substr().
ilDB::lower | ( | $a_exp | ) |
Upper.
string | expression |
Implements ilDBInterface.
Definition at line 1893 of file class.ilDB.php.
ilDB::manipulate | ( | $sql | ) |
Data manipulation.
This statement should be used for DELETE, UPDATE and INSERT statements.
Example:
string | DML string |
Implements ilDBInterface.
Definition at line 1459 of file class.ilDB.php.
References $ilBench, $r, and handleError().
Referenced by manipulateF(), ilDBPostgreSQL\replace(), and ilDBOracle\replace().
ilDB::manipulateF | ( | $a_query, | |
$a_types, | |||
$a_values | |||
) |
Formatted manupulate (for DELETE, UPDATE, INSERT).
Use s as placeholder!
string | query |
array | type array |
arraay | value array |
Implements ilDBInterface.
Definition at line 1387 of file class.ilDB.php.
References $query, $t, array, manipulate(), quote(), and raisePearError().
Referenced by assLongMenu\clearAnswerSpecificDataFromDb(), insert(), replace(), assLongMenu\saveAdditionalQuestionDataToDb(), and update().
ilDB::migrateAllTablesToEngine | ( | $engine = ilDBConstants::MYSQL_ENGINE_INNODB | ) |
string | $engine |
Definition at line 2345 of file class.ilDB.php.
References array.
ilDB::modifyTableColumn | ( | $a_table, | |
$a_column, | |||
$a_attributes | |||
) |
Modify a table column Use this only on aleady "abstracted" tables.
string | table name |
string | column name |
array | attributes to be changed, e.g. array("length" => 10, "default" => "t") |
Implements ilDBInterface.
Definition at line 691 of file class.ilDB.php.
References $def, $r, $type, array, checkColumnDefinition(), handleError(), and raisePearError().
ilDB::nextId | ( | $a_table_name | ) |
Get next ID for an index.
Implements ilDBInterface.
Definition at line 1439 of file class.ilDB.php.
References $r, and handleError().
ilDB::now | ( | ) |
Implements ilDBInterface.
Definition at line 1815 of file class.ilDB.php.
ilDB::numRows | ( | $a_set | ) |
Fetch row as associative array from result set.
object | result set |
Implements ilDBInterface.
Definition at line 1752 of file class.ilDB.php.
ilDB::prepare | ( | $a_query, | |
$a_types = null , |
|||
$a_result_types = null |
|||
) |
Prepare a query (SELECT) statement to be used with execute.
String | Query String |
Array | Placeholder Types |
Implements ilDBInterface.
Definition at line 1482 of file class.ilDB.php.
References $res, and handleError().
ilDB::prepareManip | ( | $a_query, | |
$a_types = null |
|||
) |
Prepare a data manipulation statement to be used with execute.
String | Query String |
Array | Placeholder Types |
Implements ilDBInterface.
Definition at line 1497 of file class.ilDB.php.
References $res, handleError(), and MDB2_PREPARE_MANIP.
ilDB::query | ( | $sql, | |
$a_handle_error = true |
|||
) |
Query.
Example:
For multiple similar queries/manipulations you may use prepare() and execute().
string |
Definition at line 1339 of file class.ilDB.php.
References $ilBench, $r, and handleError().
Referenced by ilCourseArchives\__read(), ilRbacSystem\checkAccessOfUser(), createDatabase(), ilRbacReview\getOperation(), ilRbacReview\getOperations(), ilRbacReview\getOperationsOnTypeString(), getRow(), ilDBOracle\initConnection(), ilRbacReview\isDeleted(), ilRbacSystem\preloadRbacPaCache(), queryF(), ilParticipants\readSubscriberData(), ilParticipants\readSubscribers(), ilRbacReview\roleExists(), and ilTestArchiver\updateTestArchive().
ilDB::queryF | ( | $a_query, | |
$a_types, | |||
$a_values | |||
) |
Formatted query (for SELECTS).
Use s as placeholder!
string | query |
array | type array |
arraay | value array |
Implements ilDBInterface.
Definition at line 1365 of file class.ilDB.php.
References $query, $t, array, query(), quote(), and raisePearError().
Referenced by assLongMenu\loadFromDb().
ilDB::quote | ( | $a_query, | |
$a_type = null |
|||
) |
Wrapper for quote method.
Implements ilDBInterface.
Definition at line 2133 of file class.ilDB.php.
References $a_type, and raisePearError().
Referenced by equals(), equalsNot(), ilRbacReview\getAssignableChildRoles(), ilTree\getNodeDataByType(), ilTree\getPathFull(), ilDBPostgreSQL\groupConcat(), ilDBMySQL\groupConcat(), in(), ilDBOracle\like(), like(), manipulateF(), queryF(), ilDBPostgreSQL\replace(), ilDBOracle\replace(), update(), and ilTestArchiver\updateTestArchive().
ilDB::quoteIdentifier | ( | $a_identifier, | |
$check_option = false |
|||
) |
Quote table and field names.
Note: IF POSSIBLE, THIS METHOD SHOULD NOT BE USED. Rename your table or field, if it conflicts with a reserved word.
Implements ilDBInterface.
Definition at line 2158 of file class.ilDB.php.
ilDB::raisePearError | ( | $a_message, | |
$a_level = "" |
|||
) |
Raise an error.
Definition at line 460 of file class.ilDB.php.
References PEAR\raiseError().
Referenced by addTableColumn(), addUniqueConstraint(), beginTransaction(), connect(), connectHost(), createTable(), dropPrimaryKey(), ilDBOracle\like(), like(), manipulateF(), modifyTableColumn(), queryF(), quote(), renameTable(), and renameTableColumn().
ilDB::renameTable | ( | $a_name, | |
$a_new_name | |||
) |
Rename a table.
string | old table name |
string | new table name |
Implements ilDBInterface.
Definition at line 812 of file class.ilDB.php.
References $r, array, checkTableName(), handleError(), and raisePearError().
ilDB::renameTableColumn | ( | $a_table, | |
$a_column, | |||
$a_new_column | |||
) |
Rename a table column Use this only on aleady "abstracted" tables.
string | table name |
string | old column name |
string | new column name |
Implements ilDBInterface.
Definition at line 766 of file class.ilDB.php.
References $def, $r, array, checkColumnName(), handleError(), and raisePearError().
ilDB::replace | ( | $a_table, | |
$a_pk_columns, | |||
$a_other_columns | |||
) |
Replace into method.
string | table name |
array | primary key values: array("field1" => array("text", $name), "field2" => ...) |
array | other values: array("field1" => array("text", $name), "field2" => ...) |
Implements ilDBInterface.
Definition at line 1674 of file class.ilDB.php.
References $r, array, free(), handleError(), manipulateF(), and MDB2_PREPARE_MANIP.
ilDB::rollback | ( | ) |
Rollback a transaction.
Implements ilDBInterface.
Definition at line 2196 of file class.ilDB.php.
References $res, handleError(), lockTables(), and unlockTables().
ilDB::sanitizeMB4StringIfNotSupported | ( | $query | ) |
$query | string to sanitize, all MB4-Characters like emojis will re replaced with ??? |
Implements ilDBInterface.
Definition at line 2384 of file class.ilDB.php.
References $query, doesCollationSupportMB4Strings(), and ilDBConstants\MB4_REPLACEMENT.
ilDB::sequenceExists | ( | $a_sequence | ) |
Check, whether a given sequence exists.
string | sequence name |
Implements ilDBInterface.
Definition at line 2096 of file class.ilDB.php.
References listSequences().
ilDB::setDBHost | ( | $a_host | ) |
Set database host.
string | database host |
Implements ilDBInterface.
Definition at line 113 of file class.ilDB.php.
Referenced by initFromIniFile().
ilDB::setDBName | ( | $a_name | ) |
Set database name.
string | database name |
Definition at line 153 of file class.ilDB.php.
Referenced by initFromIniFile().
ilDB::setDBPassword | ( | $a_password | ) |
Set database password.
string | database password |
Implements ilDBInterface.
Definition at line 133 of file class.ilDB.php.
Referenced by initFromIniFile().
ilDB::setDBPort | ( | $a_port | ) |
Set database port.
string | database port |
Implements ilDBInterface.
Definition at line 93 of file class.ilDB.php.
Referenced by initFromIniFile().
ilDB::setDBUser | ( | $a_user | ) |
Set database user.
string | database user |
Implements ilDBInterface.
Definition at line 73 of file class.ilDB.php.
Referenced by initFromIniFile().
ilDB::setLimit | ( | $a_limit, | |
$a_offset = 0 |
|||
) |
Set limit and offset for a query.
Implements ilDBInterface.
Definition at line 1431 of file class.ilDB.php.
ilDB::setSubType | ( | $a_value | ) |
Set sub type.
string | $a_value |
Definition at line 2324 of file class.ilDB.php.
References string.
ilDB::substr | ( | $a_exp, | |
$a_pos = 1 , |
|||
$a_len = -1 |
|||
) |
Substring.
Definition at line 1867 of file class.ilDB.php.
Referenced by checkColumnName(), checkTableName(), dropTable(), logStatement(), and ilDBMySQL\setMaxAllowedPacket().
ilDB::supports | ( | $feature | ) |
$feature |
Implements ilDBInterface.
Definition at line 379 of file class.ilDB.php.
References supportsFulltext(), supportsSlave(), and supportsTransactions().
ilDB::supportsEngineMigration | ( | ) |
ilDB::supportsFulltext | ( | ) |
Implements ilDBInterface.
Definition at line 359 of file class.ilDB.php.
Referenced by dropPrimaryKey(), and supports().
ilDB::supportsSlave | ( | ) |
Supports slave.
Implements ilDBInterface.
Definition at line 370 of file class.ilDB.php.
Referenced by supports(), and useSlave().
ilDB::supportsTransactions | ( | ) |
Implements ilDBInterface.
Definition at line 397 of file class.ilDB.php.
Referenced by supports().
ilDB::tableColumnExists | ( | $a_table, | |
$a_column_name | |||
) |
Checks for the existence of a table column.
string | $a_table | The table name which should be examined |
string | $a_column_name | The name of the column |
Implements ilDBInterface.
Definition at line 2023 of file class.ilDB.php.
References $r, and MDB2\isError().
ilDB::tableExists | ( | $a_table | ) |
Check, whether a given table exists.
string | table name |
Implements ilDBInterface.
Definition at line 2004 of file class.ilDB.php.
References listTables().
ilDB::uniqueConstraintExists | ( | $a_table, | |
array | $a_fields | ||
) |
Checks if a unique constraint exists based on the fields of the unique constraint (not the name)
string | $a_table | table name |
array | $a_fields | array of field names (strings) |
Definition at line 2047 of file class.ilDB.php.
ilDB::unixTimestamp | ( | ) |
Unix timestamp.
Definition at line 1988 of file class.ilDB.php.
|
abstract |
Unlock tables locked by previous lock table calls.
Implements ilDBInterface.
Referenced by rollback().
ilDB::update | ( | $a_table, | |
$a_columns, | |||
$a_where | |||
) |
Convenient method for standard update statements, example field array:
array("field1" => array("text", $name), // will use "%s" "field2" => array("integer", $id), // will use "%s"
Example where array: array("id" => array("integer", $id))
Implements ilDBInterface.
Definition at line 1596 of file class.ilDB.php.
References $r, array, free(), handleError(), manipulateF(), MDB2_PREPARE_MANIP, and quote().
ilDB::upper | ( | $a_exp | ) |
Upper.
string | expression |
Implements ilDBInterface.
Definition at line 1882 of file class.ilDB.php.
ilDB::useSlave | ( | $a_val = true | ) |
Use slave.
Implements ilDBInterface.
Definition at line 409 of file class.ilDB.php.
References supportsSlave().
ilDB::$allowed_attributes |
Definition at line 55 of file class.ilDB.php.
Referenced by checkColumnDefinition(), and getAllowedAttributes().
ilDB::$db |
Definition at line 46 of file class.ilDB.php.
ilDB::$error_class |
Definition at line 40 of file class.ilDB.php.
ilDB::$result |
Definition at line 52 of file class.ilDB.php.
ilDB::$sub_type |
Definition at line 66 of file class.ilDB.php.
Referenced by getSubType().
const ilDB::LOCK_READ = 2 |
Definition at line 32 of file class.ilDB.php.
const ilDB::LOCK_WRITE = 1 |
Definition at line 31 of file class.ilDB.php.