ILIAS
Release_5_0_x_branch Revision 61816
|
Database Wrapper. More...
Public Member Functions | |
ilDB () | |
constructor | |
setDBUser ($a_user) | |
Set database user. | |
getDBUser () | |
Get database user. | |
setDBPort ($a_port) | |
Set database port. | |
getDBPort () | |
Get database port. | |
setDBHost ($a_host) | |
Set database host. | |
getDBHost () | |
Get database host. | |
setDBPassword ($a_password) | |
Set database password. | |
getDBPassword () | |
Get database password. | |
setDBName ($a_name) | |
Set database name. | |
getDBName () | |
Get database name. | |
getDSN () | |
Get DSN. | |
getDBVersion () | |
Get DB version. | |
getDBType () | |
Get DSN. | |
enableResultBuffering ($a_status) | |
En/disable result buffering. | |
initFromIniFile ($tmpClientIniFile=null) | |
Init db parameters from ini file. | |
connect ($a_return_false_for_error=false) | |
Open the connection. | |
doConnect () | |
Standard way to connect to db. | |
disconnect () | |
Disconnect. | |
getHostDSN () | |
Should return a valid value, if host connections are possible (connectHost) to create a new database from scratch. | |
connectHost () | |
Sets up a host connection only (no specific database used). | |
supportsFulltext () | |
supportsSlave () | |
Supports slave. | |
useSlave ($a_val=true) | |
Use slave. | |
handleError ($a_res, $a_info="", $a_level="") | |
Handle MDB2 Errors. | |
raisePearError ($a_message, $a_level="") | |
Raise an error. | |
createDatabase ($a_name, $a_charset="utf8", $a_collation="") | |
Create database. | |
createTable ($a_name, $a_definition_array, $a_drop_table=false, $a_ignore_erros=false) | |
Create a new table in the database. | |
dropTable ($a_name, $a_error_if_not_existing=true) | |
Drop a table. | |
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. | |
addTableColumn ($a_table, $a_column, $a_attributes) | |
Add table column Use this only on aleady "abstracted" tables. | |
dropTableColumn ($a_table, $a_column) | |
Drop table column Use this only on aleady "abstracted" tables. | |
modifyTableColumn ($a_table, $a_column, $a_attributes) | |
Modify a table column Use this only on aleady "abstracted" tables. | |
renameTableColumn ($a_table, $a_column, $a_new_column) | |
Rename a table column Use this only on aleady "abstracted" tables. | |
renameTable ($a_name, $a_new_name) | |
Rename a table. | |
addPrimaryKey ($a_table, $a_fields) | |
Add a primary key to a table. | |
getPrimaryKeyIdentifier () | |
Primary key identifier. | |
dropPrimaryKey ($a_table) | |
Drop a primary key from a table. | |
addIndex ($a_table, $a_fields, $a_name="in", $a_fulltext=false) | |
Add an index to a table. | |
addFulltextIndex ($a_table, $a_fields, $a_name="in") | |
Add fulltext index. | |
isFulltextIndex ($a_table, $a_name) | |
Is index a fulltext index? | |
indexExistsByFields ($a_table, $a_fields) | |
Check if index exists. | |
dropIndexByFields ($a_table, $a_fields) | |
Drop index by field(s) | |
dropIndex ($a_table, $a_name="in") | |
Drop an index from a table. | |
addUniqueConstraint ($a_table, $a_fields, $a_name="con") | |
Add a unique constraint to a table. | |
createSequence ($a_table_name, $a_start=1) | |
Create a sequence for a table. | |
dropSequence ($a_table_name) | |
Drop a sequence for a table. | |
checkTableName ($a_name) | |
Check whether a table name is valid. | |
checkTableColumns ($a_cols) | |
Check table columns definition. | |
checkColumn ($a_col, $a_def) | |
Check column definition. | |
checkColumnDefinition ($a_def, $a_modify_mode=false) | |
Check whether a column definition is valid. | |
checkColumnName ($a_name) | |
Check whether a column name is valid. | |
checkIndexName ($a_name) | |
Check whether an index name is valid. | |
getAllowedAttributes () | |
constraintName ($a_table, $a_constraint) | |
Determine contraint name by table name and constraint name. | |
query ($sql, $a_handle_error=true) | |
Query. | |
queryF ($a_query, $a_types, $a_values) | |
Formatted query (for SELECTS). | |
manipulateF ($a_query, $a_types, $a_values) | |
Formatted manupulate (for DELETE, UPDATE, INSERT). | |
logStatement ($sql) | |
Helper function, should usually not be called. | |
setLimit ($a_limit, $a_offset=0) | |
Set limit and offset for a query. | |
nextId ($a_table_name) | |
Get next ID for an index. | |
manipulate ($sql) | |
Data manipulation. | |
prepare ($a_query, $a_types=null, $a_result_types=null) | |
Prepare a query (SELECT) statement to be used with execute. | |
prepareManip ($a_query, $a_types=null) | |
Prepare a data manipulation statement to be used with execute. | |
execute ($a_stmt, $a_data=null) | |
Execute a query statement prepared by either prepare() or prepareManip() | |
executeMultiple ($a_stmt, $a_data) | |
Execute a query statement prepared by either prepare() or prepareManip() with multiple data arrays. | |
insert ($a_table, $a_columns) | |
Convenient method for standard insert statements, example field array: | |
update ($a_table, $a_columns, $a_where) | |
Convenient method for standard update statements, example field array: | |
replace ($a_table, $a_pk_columns, $a_other_columns) | |
Replace into method. | |
fetchAssoc ($a_set) | |
Fetch row as associative array from result set. | |
free ($a_st) | |
Free a statement / result set. | |
fetchObject ($a_set) | |
Fetch row as object from result set. | |
numRows ($a_set) | |
Fetch row as associative array from result set. | |
in ($a_field, $a_values, $negate=false, $a_type="") | |
Get abstract in-clause for given array. | |
addTypesToArray ($a_arr, $a_type, $a_cnt) | |
Adds a type x times to an array. | |
now () | |
now() | |
concat ($a_values, $a_allow_null=true) | |
Abstraction of SQL function CONCAT. | |
substr ($a_exp, $a_pos=1, $a_len=-1) | |
Substring. | |
upper ($a_exp) | |
Upper. | |
lower ($a_exp) | |
Upper. | |
locate ($a_needle, $a_string, $a_start_pos=1) | |
Create locate string. | |
like ($a_col, $a_type, $a_value="?", $case_insensitive=true) | |
Like. | |
equals ($a_col, $a_value, $a_type, $a_empty_or_null=false) | |
Use this only on text fields. | |
equalsNot ($a_col, $a_value, $a_type, $a_empty_or_null=false) | |
Use this only on text fields. | |
fromUnixtime ($a_expr, $a_to_text=true) | |
fromUnixtime (makes timestamp out of unix timestamp) | |
unixTimestamp () | |
Unix timestamp. | |
optimizeTable ($a_table) | |
Optimize Table. | |
tableExists ($a_table) | |
Check, whether a given table exists. | |
tableColumnExists ($a_table, $a_column_name) | |
Checks for the existence of a table column. | |
uniqueConstraintExists ($a_table, $a_fields) | |
Checks if a unique constraint exists based on the fields of the unique constraint (not the name) | |
listTables () | |
Get all tables. | |
sequenceExists ($a_sequence) | |
Check, whether a given sequence exists. | |
listSequences () | |
Get all sequences. | |
quote ($a_query, $a_type=null) | |
Wrapper for quote method. | |
quoteIdentifier ($a_identifier) | |
Quote table and field names. | |
beginTransaction () | |
Begin Transaction. | |
commit () | |
Commit a transaction. | |
rollback () | |
Rollback a transaction. | |
lockTables ($a_tables) | |
Abstraction of lock table. | |
unlockTables () | |
Unlock tables locked by previous lock table calls. | |
autoExecute ($a_tablename, $a_fields, $a_mode=MDB2_AUTOQUERY_INSERT, $a_where=false) | |
Wrapper for Pear autoExecute. | |
getLastInsertId () | |
Get last insert id. | |
getOne ($sql) | |
getOne. | |
getRow ($sql, $mode=DB_FETCHMODE_OBJECT) | |
getRow. | |
setSubType ($a_value) | |
Set sub type. | |
getSubType () | |
Get sub type. | |
Public Member Functions inherited from PEAR | |
PEAR ($error_class=null) | |
Constructor. | |
_PEAR () | |
Destructor (the emulated type of...). | |
& | 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. | |
registerShutdownFunc ($func, $args=array()) | |
Use this function to register a shutdown method for static classes. | |
isError ($data, $code=null) | |
Tell whether a value is a PEAR error. | |
setErrorHandling ($mode=null, $options=null) | |
Sets how errors generated by this object should be handled. | |
expectError ($code= '*') | |
This method is used to tell which errors you expect to get. | |
popExpect () | |
This method pops one element off the expected error codes stack. | |
_checkDelExpect ($error_code) | |
This method checks unsets an error code if available. | |
delExpect ($error_code) | |
This method deletes all occurences of the specified element from the expected error codes stack. | |
& | 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. | |
& | throwError ($message=null, $code=null, $userinfo=null) |
Simpler form of raiseError with fewer options. | |
staticPushErrorHandling ($mode, $options=null) | |
staticPopErrorHandling () | |
pushErrorHandling ($mode, $options=null) | |
Push a new error handler on top of the error handler options stack. | |
popErrorHandling () | |
Pop the last error handler used. | |
loadExtension ($ext) | |
OS independant PHP extension load. |
Static Public Member Functions | |
static | getReservedWords () |
Get reserved words. | |
static | isDbError ($a_res) |
Check error. | |
static | isReservedWord ($a_word) |
Checks whether a word is a reserved word in one of the supported databases. |
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. | |
initHostConnection () | |
Initialize the host connection (no specific database) | |
loadMDB2Extensions () | |
load additional mdb2 extensions and set their constants | |
getCreateTableOptions () | |
Get options for the create table statement. |
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 28 of file class.ilDB.php.
ilDB::addFulltextIndex | ( | $a_table, | |
$a_fields, | |||
$a_name = "in" |
|||
) |
Add fulltext index.
Reimplemented in ilDBMySQL.
Definition at line 984 of file class.ilDB.php.
Referenced by addIndex().
ilDB::addIndex | ( | $a_table, | |
$a_fields, | |||
$a_name = "in" , |
|||
$a_fulltext = false |
|||
) |
Add an index to a table.
string | table name |
array | fields for index |
string | index name |
Definition at line 946 of file class.ilDB.php.
References addFulltextIndex(), checkIndexName(), constraintName(), handleError(), raisePearError(), and supportsFulltext().
ilDB::addPrimaryKey | ( | $a_table, | |
$a_fields | |||
) |
Add a primary key to a table.
string | table name |
array | fields for primary key |
string | key name |
Definition at line 896 of file class.ilDB.php.
References 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") |
Definition at line 675 of file class.ilDB.php.
References checkColumnDefinition(), checkColumnName(), handleError(), and raisePearError().
ilDB::addTypesToArray | ( | $a_arr, | |
$a_type, | |||
$a_cnt | |||
) |
Adds a type x times to an array.
Definition at line 1897 of file class.ilDB.php.
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 1080 of file class.ilDB.php.
References 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 654 of file class.ilDB.php.
References 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 2387 of file class.ilDB.php.
References $res, and handleError().
ilDB::beginTransaction | ( | ) |
Begin Transaction.
Please note that we currently do not use savepoints.
Definition at line 2328 of file class.ilDB.php.
References $res, handleError(), and raisePearError().
ilDB::checkColumn | ( | $a_col, | |
$a_def | |||
) |
Check column definition.
Definition at line 1186 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 1206 of file class.ilDB.php.
References $allowed_attributes.
Referenced by addTableColumn(), checkColumn(), and modifyTableColumn().
ilDB::checkColumnName | ( | $a_name | ) |
Check whether a column name is valid.
string | $a_name |
Definition at line 1280 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 1314 of file class.ilDB.php.
References isReservedWord().
Referenced by addIndex(), and addUniqueConstraint().
ilDB::checkTableColumns | ( | $a_cols | ) |
Check table columns definition.
array | definition array |
Definition at line 1170 of file class.ilDB.php.
References checkColumn().
Referenced by createTable().
ilDB::checkTableName | ( | $a_name | ) |
Check whether a table name is valid.
string | $a_name |
Definition at line 1136 of file class.ilDB.php.
References isReservedWord(), and substr().
Referenced by createTable(), and renameTable().
ilDB::commit | ( | ) |
Commit a transaction.
Definition at line 2342 of file class.ilDB.php.
References $res, and handleError().
ilDB::concat | ( | $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 |
Reimplemented in ilDBOracle.
Definition at line 1933 of file class.ilDB.php.
ilDB::connect | ( | $a_return_false_for_error = false | ) |
Open the connection.
Definition at line 241 of file class.ilDB.php.
References doConnect(), getDSN(), handleError(), initConnection(), isDbError(), MDB2\isError(), loadMDB2Extensions(), MDB2_PORTABILITY_ALL, PEAR_ERROR_CALLBACK, raisePearError(), and PEAR\setErrorHandling().
Referenced by connectHost(), ilDBOracle\doConnect(), doConnect(), and ilDBMySQL\doConnect().
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 320 of file class.ilDB.php.
References 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)
Reimplemented in ilDBOracle, and ilDBPostgreSQL.
Definition at line 1347 of file class.ilDB.php.
Referenced by ilDBMySQL\addFulltextIndex(), addIndex(), addPrimaryKey(), addUniqueConstraint(), ilDBMySQL\dropFulltextIndex(), dropIndex(), and dropPrimaryKey().
ilDB::createDatabase | ( | $a_name, | |
$a_charset = "utf8" , |
|||
$a_collation = "" |
|||
) |
Create database.
Definition at line 527 of file class.ilDB.php.
References query().
ilDB::createSequence | ( | $a_table_name, | |
$a_start = 1 |
|||
) |
Create a sequence for a table.
Definition at line 1109 of file class.ilDB.php.
References 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 |
Definition at line 552 of file class.ilDB.php.
References $options, checkTableColumns(), checkTableName(), dropTable(), getCreateTableOptions(), handleError(), and raisePearError().
ilDB::disconnect | ( | ) |
ilDB::doConnect | ( | ) |
Standard way to connect to db.
Reimplemented in ilDBMySQL, and ilDBOracle.
Definition at line 280 of file class.ilDB.php.
References connect(), and getDSN().
Referenced by connect().
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 |
Definition at line 1057 of file class.ilDB.php.
References constraintName(), handleError(), and isFulltextIndex().
Referenced by dropIndexByFields().
ilDB::dropIndexByFields | ( | $a_table, | |
$a_fields | |||
) |
Drop index by field(s)
type | $a_table | |
type | $a_fields |
Definition at line 1029 of file class.ilDB.php.
References dropIndex().
ilDB::dropPrimaryKey | ( | $a_table | ) |
Drop a primary key from a table.
string | table name |
string | key name |
Reimplemented in ilDBOracle.
Definition at line 929 of file class.ilDB.php.
References constraintName(), getPrimaryKeyIdentifier(), and handleError().
ilDB::dropSequence | ( | $a_table_name | ) |
Drop a sequence for a table.
Definition at line 1122 of file class.ilDB.php.
References 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 |
Definition at line 598 of file class.ilDB.php.
References 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 |
Definition at line 709 of file class.ilDB.php.
References handleError().
ilDB::enableResultBuffering | ( | $a_status | ) |
En/disable result buffering.
bool | $a_status |
Definition at line 209 of file class.ilDB.php.
ilDB::equals | ( | $a_col, | |
$a_value, | |||
$a_type, | |||
$a_empty_or_null = false |
|||
) |
Use this only on text fields.
Definition at line 2068 of file class.ilDB.php.
References quote().
ilDB::equalsNot | ( | $a_col, | |
$a_value, | |||
$a_type, | |||
$a_empty_or_null = false |
|||
) |
Use this only on text fields.
Definition at line 2083 of file class.ilDB.php.
References 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) |
Definition at line 1583 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 1599 of file class.ilDB.php.
References $res, and handleError().
ilDB::fetchAssoc | ( | $a_set | ) |
Fetch row as associative array from result set.
object | result set |
Definition at line 1818 of file class.ilDB.php.
References DB_FETCHMODE_ASSOC.
Referenced by ilObjTestDynamicQuestionSetConfig\getPoolQuestionChangeListener(), ilDBMySQL\isFulltextIndex(), and ilTestArchiver\updateTestArchive().
ilDB::fetchObject | ( | $a_set | ) |
Fetch row as object from result set.
object | result set |
Definition at line 1836 of file class.ilDB.php.
References DB_FETCHMODE_OBJECT.
ilDB::free | ( | $a_st | ) |
Free a statement / result set.
Definition at line 1826 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 |
Reimplemented in ilDBOracle.
Definition at line 2106 of file class.ilDB.php.
ilDB::getAllowedAttributes | ( | ) |
Definition at line 1337 of file class.ilDB.php.
References $allowed_attributes.
|
protected |
Get options for the create table statement.
Reimplemented in ilDBMySQL, and ilDBInnoDB.
Definition at line 587 of file class.ilDB.php.
Referenced by createTable().
ilDB::getDBHost | ( | ) |
Get database host.
string | database host |
Definition at line 133 of file class.ilDB.php.
References $db_host.
Referenced by ilDBPostgreSQL\getDSN(), ilDBOracle\getDSN(), and ilDBMySQL\getDSN().
ilDB::getDBName | ( | ) |
Get database name.
string | database name |
Definition at line 173 of file class.ilDB.php.
References $db_name.
Referenced by ilDBPostgreSQL\getDSN(), ilDBOracle\getDSN(), and ilDBMySQL\getDSN().
ilDB::getDBPassword | ( | ) |
Get database password.
string | database password |
Definition at line 153 of file class.ilDB.php.
Referenced by ilDBPostgreSQL\getDSN(), ilDBOracle\getDSN(), ilDBMySQL\getDSN(), and ilDBMySQL\getHostDSN().
ilDB::getDBPort | ( | ) |
Get database port.
string | database port |
Definition at line 113 of file class.ilDB.php.
Referenced by ilDBOracle\getDSN(), and ilDBMySQL\getDSN().
|
abstract |
Get DSN.
This must be overwritten in DBMS specific class.
Reimplemented in ilDBMySQL, ilDBOracle, ilDBPostgreSQL, and ilDBInnoDB.
Referenced by dropTable().
ilDB::getDBUser | ( | ) |
Get database user.
string | database user |
Definition at line 93 of file class.ilDB.php.
References $db_user.
Referenced by ilDBOracle\getDSN(), ilDBMySQL\getDSN(), and ilDBMySQL\getHostDSN().
ilDB::getDBVersion | ( | ) |
Get DB version.
Reimplemented in ilDBMySQL, and ilDBOracle.
Definition at line 186 of file class.ilDB.php.
|
abstract |
Get DSN.
This must be overwritten in DBMS specific class.
Reimplemented in ilDBMySQL, ilDBOracle, and ilDBPostgreSQL.
Referenced by connect(), and doConnect().
ilDB::getHostDSN | ( | ) |
Should return a valid value, if host connections are possible (connectHost) to create a new database from scratch.
Reimplemented in ilDBMySQL.
Definition at line 311 of file class.ilDB.php.
Referenced by connectHost().
ilDB::getLastInsertId | ( | ) |
Get last insert id.
Definition at line 2403 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 2422 of file class.ilDB.php.
References DB_FETCHMODE_ASSOC, handleError(), and MDB2\isError().
ilDB::getPrimaryKeyIdentifier | ( | ) |
Primary key identifier.
Reimplemented in ilDBOracle, and ilDBPostgreSQL.
Definition at line 918 of file class.ilDB.php.
Referenced by addPrimaryKey(), and dropPrimaryKey().
|
staticabstract |
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.
Reimplemented in ilDBMySQL, ilDBOracle, and ilDBPostgreSQL.
Referenced by isReservedWord().
ilDB::getRow | ( | $sql, | |
$mode = DB_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 2446 of file class.ilDB.php.
References handleError(), and query().
ilDB::getSubType | ( | ) |
Get sub type.
Definition at line 2472 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 405 of file class.ilDB.php.
References $ilLog, MDB2\isError(), and raisePearError().
Referenced by addIndex(), addPrimaryKey(), addTableColumn(), addUniqueConstraint(), alterTable(), autoExecute(), beginTransaction(), commit(), connect(), connectHost(), createSequence(), createTable(), dropIndex(), ilDBOracle\dropPrimaryKey(), dropPrimaryKey(), dropSequence(), dropTable(), dropTableColumn(), execute(), executeMultiple(), getOne(), getRow(), insert(), manipulate(), modifyTableColumn(), nextId(), prepare(), prepareManip(), ilDBMySQL\query(), query(), renameTable(), renameTableColumn(), ilDBPostgreSQL\replace(), ilDBOracle\replace(), replace(), rollback(), and update().
ilDB::ilDB | ( | ) |
constructor
set up database conncetion and the errorhandling
string | dsn database-connection-string for pear-db |
Definition at line 74 of file class.ilDB.php.
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);
Reimplemented in ilDBOracle.
Definition at line 1866 of file class.ilDB.php.
ilDB::indexExistsByFields | ( | $a_table, | |
$a_fields | |||
) |
Check if index exists.
type | $a_table | |
type | $a_fields |
Definition at line 1003 of file class.ilDB.php.
|
protected |
Initialize the database connection.
Reimplemented in ilDBMySQL, ilDBOracle, ilDBPostgreSQL, and ilDBInnoDB.
Definition at line 301 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 |
Reimplemented in ilDBMySQL.
Definition at line 218 of file class.ilDB.php.
References setDBHost(), setDBName(), setDBPassword(), setDBPort(), and setDBUser().
|
protected |
Initialize the host connection (no specific database)
Definition at line 364 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))
Definition at line 1612 of file class.ilDB.php.
References free(), handleError(), manipulateF(), and MDB2_PREPARE_MANIP.
Referenced by ilDBPostgreSQL\replace(), and ilDBOracle\replace().
|
static |
Check error.
Definition at line 515 of file class.ilDB.php.
References PEAR\isError().
Referenced by connect(), connectHost(), ilNestedSetXML\export(), and loadMDB2Extensions().
ilDB::isFulltextIndex | ( | $a_table, | |
$a_name | |||
) |
Is index a fulltext index?
Reimplemented in ilDBMySQL.
Definition at line 992 of file class.ilDB.php.
Referenced by dropIndex().
|
static |
Checks whether a word is a reserved word in one of the supported databases.
Definition at line 1356 of file class.ilDB.php.
References getReservedWords().
Referenced by checkColumnName(), checkIndexName(), and checkTableName().
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) |
Reimplemented in ilDBOracle.
Definition at line 2032 of file class.ilDB.php.
References quote(), and raisePearError().
ilDB::listSequences | ( | ) |
Get all sequences.
Definition at line 2264 of file class.ilDB.php.
References MDB2\isError().
Referenced by sequenceExists().
ilDB::listTables | ( | ) |
Get all tables.
Definition at line 2226 of file class.ilDB.php.
References MDB2\isError().
Referenced by dropTable(), and tableExists().
|
protected |
load additional mdb2 extensions and set their constants
protected
Definition at line 500 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] |
Reimplemented in ilDBOracle.
Definition at line 2014 of file class.ilDB.php.
|
abstract |
Abstraction of lock table.
array | table definitions |
Reimplemented in ilDBMySQL, ilDBOracle, and ilDBPostgreSQL.
ilDB::logStatement | ( | $sql | ) |
Helper function, should usually not be called.
Definition at line 1466 of file class.ilDB.php.
References substr().
ilDB::lower | ( | $a_exp | ) |
Upper.
string | expression |
Definition at line 2002 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 |
Definition at line 1528 of file class.ilDB.php.
References $ilBench, 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 |
Definition at line 1446 of file class.ilDB.php.
References $query, $t, manipulate(), quote(), and raisePearError().
Referenced by insert(), replace(), and update().
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") |
Definition at line 733 of file class.ilDB.php.
References checkColumnDefinition(), handleError(), and raisePearError().
ilDB::nextId | ( | $a_table_name | ) |
Get next ID for an index.
Definition at line 1508 of file class.ilDB.php.
References handleError().
ilDB::now | ( | ) |
Reimplemented in ilDBMySQL, ilDBOracle, and ilDBPostgreSQL.
Definition at line 1918 of file class.ilDB.php.
ilDB::numRows | ( | $a_set | ) |
Fetch row as associative array from result set.
object | result set |
Definition at line 1846 of file class.ilDB.php.
ilDB::optimizeTable | ( | $a_table | ) |
Optimize Table.
Reimplemented in ilDBMySQL.
Definition at line 2122 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 |
Definition at line 1553 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 |
Definition at line 1568 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 |
Reimplemented in ilDBMySQL.
Definition at line 1393 of file class.ilDB.php.
References $ilBench, and handleError().
Referenced by ilCourseArchives\__read(), ilRbacSystem\checkAccessOfUser(), createDatabase(), ilRbacReview\getOperation(), ilRbacReview\getOperations(), ilRbacReview\getOperationsOnTypeString(), ilRbacReview\getRoleMailboxAddress(), getRow(), ilDBOracle\initConnection(), ilRbacReview\isDeleted(), ilRbacSystem\preloadRbacPaCache(), queryF(), ilParticipants\readSubscriberData(), ilParticipants\readSubscribers(), ilRbacReview\roleExists(), ilRbacReview\searchRolesByMailboxAddressList(), 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 |
Definition at line 1422 of file class.ilDB.php.
References $query, $t, query(), quote(), and raisePearError().
Referenced by ilObjTestDynamicQuestionSetConfig\getPoolQuestionChangeListener().
ilDB::quote | ( | $a_query, | |
$a_type = null |
|||
) |
Wrapper for quote method.
Definition at line 2285 of file class.ilDB.php.
References raisePearError().
Referenced by equals(), equalsNot(), ilTree\getNodeDataByType(), ilTree\getPathFull(), ilDBOracle\like(), like(), manipulateF(), queryF(), ilDBPostgreSQL\replace(), ilDBOracle\replace(), ilRbacReview\searchRolesByMailboxAddressList(), update(), and ilTestArchiver\updateTestArchive().
ilDB::quoteIdentifier | ( | $a_identifier | ) |
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.
Definition at line 2313 of file class.ilDB.php.
ilDB::raisePearError | ( | $a_message, | |
$a_level = "" |
|||
) |
Raise an error.
Definition at line 485 of file class.ilDB.php.
References PEAR\raiseError().
Referenced by addIndex(), addTableColumn(), addUniqueConstraint(), beginTransaction(), connect(), connectHost(), createTable(), handleError(), 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 |
Definition at line 869 of file class.ilDB.php.
References $query, 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 |
Definition at line 819 of file class.ilDB.php.
References 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" => ...) |
Reimplemented in ilDBOracle, and ilDBPostgreSQL.
Definition at line 1762 of file class.ilDB.php.
References free(), handleError(), manipulateF(), and MDB2_PREPARE_MANIP.
ilDB::rollback | ( | ) |
Rollback a transaction.
Definition at line 2352 of file class.ilDB.php.
References $res, and handleError().
ilDB::sequenceExists | ( | $a_sequence | ) |
Check, whether a given sequence exists.
string | sequence name |
Definition at line 2245 of file class.ilDB.php.
References listSequences().
ilDB::setDBHost | ( | $a_host | ) |
Set database host.
string | database host |
Definition at line 123 of file class.ilDB.php.
Referenced by initFromIniFile().
ilDB::setDBName | ( | $a_name | ) |
Set database name.
string | database name |
Definition at line 163 of file class.ilDB.php.
Referenced by initFromIniFile().
ilDB::setDBPassword | ( | $a_password | ) |
Set database password.
string | database password |
Definition at line 143 of file class.ilDB.php.
Referenced by initFromIniFile().
ilDB::setDBPort | ( | $a_port | ) |
Set database port.
string | database port |
Definition at line 103 of file class.ilDB.php.
Referenced by initFromIniFile().
ilDB::setDBUser | ( | $a_user | ) |
Set database user.
string | database user |
Definition at line 83 of file class.ilDB.php.
Referenced by initFromIniFile().
ilDB::setLimit | ( | $a_limit, | |
$a_offset = 0 |
|||
) |
Set limit and offset for a query.
Definition at line 1500 of file class.ilDB.php.
ilDB::setSubType | ( | $a_value | ) |
Set sub type.
string | $a_value |
Definition at line 2462 of file class.ilDB.php.
ilDB::substr | ( | $a_exp, | |
$a_pos = 1 , |
|||
$a_len = -1 |
|||
) |
Substring.
@return |
Definition at line 1975 of file class.ilDB.php.
Referenced by checkColumnName(), checkTableName(), dropTable(), logStatement(), and ilDBMySQL\setMaxAllowedPacket().
ilDB::supportsFulltext | ( | ) |
Reimplemented in ilDBMySQL, ilDBOracle, ilDBPostgreSQL, and ilDBInnoDB.
Definition at line 368 of file class.ilDB.php.
Referenced by addIndex().
ilDB::supportsSlave | ( | ) |
Supports slave.
@return |
Reimplemented in ilDBMySQL.
Definition at line 379 of file class.ilDB.php.
Referenced by useSlave().
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 |
Definition at line 2159 of file class.ilDB.php.
References MDB2\isError().
ilDB::tableExists | ( | $a_table | ) |
Check, whether a given table exists.
string | table name |
Definition at line 2138 of file class.ilDB.php.
References listTables().
ilDB::uniqueConstraintExists | ( | $a_table, | |
$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 2187 of file class.ilDB.php.
ilDB::unixTimestamp | ( | ) |
Unix timestamp.
Reimplemented in ilDBOracle.
Definition at line 2114 of file class.ilDB.php.
|
abstract |
Unlock tables locked by previous lock table calls.
Reimplemented in ilDBMySQL, ilDBOracle, and ilDBPostgreSQL.
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))
Definition at line 1673 of file class.ilDB.php.
References free(), handleError(), manipulateF(), MDB2_PREPARE_MANIP, and quote().
ilDB::upper | ( | $a_exp | ) |
Upper.
string | expression |
Definition at line 1991 of file class.ilDB.php.
ilDB::useSlave | ( | $a_val = true | ) |
Use slave.
@return |
Definition at line 390 of file class.ilDB.php.
References supportsSlave().
ilDB::$allowed_attributes |
Definition at line 54 of file class.ilDB.php.
Referenced by checkColumnDefinition(), and getAllowedAttributes().
ilDB::$db |
Definition at line 45 of file class.ilDB.php.
ilDB::$error_class |
Definition at line 39 of file class.ilDB.php.
ilDB::$result |
Definition at line 51 of file class.ilDB.php.
ilDB::$sub_type |
Definition at line 65 of file class.ilDB.php.
Referenced by getSubType().
const ilDB::LOCK_READ = 2 |
Definition at line 31 of file class.ilDB.php.
Referenced by ilDBPostgreSQL\lockTables(), ilDBOracle\lockTables(), and ilDBMySQL\lockTables().
const ilDB::LOCK_WRITE = 1 |
Definition at line 30 of file class.ilDB.php.
Referenced by ilChangeEvent\_syncObjectStats(), ilRbacAdmin\assignUserLimited(), ilGlossaryDefinition\create(), ilObjectActivation\createDefaultEntry(), ilSessionStatistics\createNewAggregationSlot(), ilGlossaryDefinition\delete(), ilNestedSetTree\deleteTree(), ilAssQuestionProcessLockerDb\getTablesUsedDuringAssessmentLog(), ilNestedSetTree\insertNode(), ilMaterializedPathTree\insertNode(), ilDBPostgreSQL\lockTables(), ilDBOracle\lockTables(), ilDBMySQL\lockTables(), ilGlossaryDefinition\moveDown(), ilForumTopic\movePosts(), ilMaterializedPathTree\moveToTrash(), ilMaterializedPathTree\moveTree(), ilNestedSetTree\moveTree(), ilGlossaryDefinition\moveUp(), ilTree\renumber(), ilTestProcessLockerDb\requestRandomPassBuildLock(), ilTestProcessLockerDb\requestTestStartLockCheckLock(), ilAssQuestionProcessLockerDb\requestUserQuestionResultUpdateLock(), ilAssQuestionProcessLockerDb\requestUserSolutionUpdateLock(), ilAssQuestionProcessLockerDb\requestUserTestResultUpdateLock(), ilTree\saveSubTree(), ilDBUpdateNewObjectType\varchar2text(), and ilWikiStat\writeData().