ILIAS
eassessment Revision 61809
|
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. | |
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 () | |
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? | |
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. | |
listTables () | |
Get all tables. | |
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. | |
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 | |
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 |
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 888 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 850 of file class.ilDB.php.
References $f, 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 800 of file class.ilDB.php.
References $f, 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 585 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 1713 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 931 of file class.ilDB.php.
References $f, 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 564 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 2122 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 2063 of file class.ilDB.php.
References $res, handleError(), and raisePearError().
ilDB::checkColumn | ( | $a_col, | |
$a_def | |||
) |
Check column definition.
Definition at line 1037 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 1057 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 1131 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 1165 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 1021 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 987 of file class.ilDB.php.
References isReservedWord(), and substr().
Referenced by createTable(), and renameTable().
ilDB::commit | ( | ) |
Commit a transaction.
Definition at line 2077 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 1749 of file class.ilDB.php.
ilDB::connect | ( | $a_return_false_for_error = false | ) |
Open the connection.
Definition at line 229 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(), and 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 308 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.
Definition at line 1198 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 443 of file class.ilDB.php.
References query().
ilDB::createSequence | ( | $a_table_name, | |
$a_start = 1 |
|||
) |
Create a sequence for a table.
Definition at line 960 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 468 of file class.ilDB.php.
References checkTableColumns(), checkTableName(), dropTable(), handleError(), and raisePearError().
ilDB::disconnect | ( | ) |
ilDB::doConnect | ( | ) |
Standard way to connect to db.
Reimplemented in ilDBOracle.
Definition at line 268 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 908 of file class.ilDB.php.
References constraintName(), handleError(), and isFulltextIndex().
ilDB::dropPrimaryKey | ( | $a_table | ) |
Drop a primary key from a table.
string | table name |
string | key name |
Definition at line 833 of file class.ilDB.php.
References constraintName(), getPrimaryKeyIdentifier(), and handleError().
ilDB::dropSequence | ( | $a_table_name | ) |
Drop a sequence for a table.
Definition at line 973 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 508 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 619 of file class.ilDB.php.
References handleError().
ilDB::equals | ( | $a_col, | |
$a_value, | |||
$a_type, | |||
$a_empty_or_null = false |
|||
) |
Use this only on text fields.
Definition at line 1884 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 1899 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 1424 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 1440 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 1637 of file class.ilDB.php.
References DB_FETCHMODE_ASSOC.
Referenced by ilDBMySQL\isFulltextIndex().
ilDB::fetchObject | ( | $a_set | ) |
Fetch row as object from result set.
object | result set |
Definition at line 1655 of file class.ilDB.php.
References DB_FETCHMODE_OBJECT.
ilDB::free | ( | $a_st | ) |
Free a statement / result set.
Definition at line 1645 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 1922 of file class.ilDB.php.
ilDB::getAllowedAttributes | ( | ) |
Definition at line 1188 of file class.ilDB.php.
References $allowed_attributes.
ilDB::getDBHost | ( | ) |
Get database host.
string | database host |
Definition at line 131 of file class.ilDB.php.
References $db_host.
Referenced by ilDBPostgreSQL\getDSN(), and ilDBOracle\getDSN().
ilDB::getDBName | ( | ) |
Get database name.
string | database name |
Definition at line 171 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 151 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 111 of file class.ilDB.php.
Referenced by ilDBOracle\getDSN().
|
abstract |
Get DSN.
This must be overwritten in DBMS specific class.
Reimplemented in ilDBMySQL, ilDBOracle, and ilDBPostgreSQL.
Referenced by dropTable().
ilDB::getDBUser | ( | ) |
Get database user.
string | database user |
Definition at line 91 of file class.ilDB.php.
References $db_user.
Referenced by ilDBOracle\getDSN().
ilDB::getDBVersion | ( | ) |
Get DB version.
Reimplemented in ilDBMySQL, and ilDBOracle.
Definition at line 184 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 299 of file class.ilDB.php.
Referenced by connectHost().
ilDB::getLastInsertId | ( | ) |
Get last insert id.
Definition at line 2138 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 2157 of file class.ilDB.php.
References DB_FETCHMODE_ASSOC, handleError(), and MDB2\isError().
ilDB::getPrimaryKeyIdentifier | ( | ) |
Primary key identifier.
Reimplemented in ilDBOracle.
Definition at line 822 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 ilDBOracle, ilDBMySQL, 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 2181 of file class.ilDB.php.
References handleError(), and query().
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 367 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(), dropPrimaryKey(), dropSequence(), dropTable(), dropTableColumn(), execute(), executeMultiple(), getOne(), getRow(), insert(), manipulate(), modifyTableColumn(), nextId(), prepare(), prepareManip(), query(), renameTable(), renameTableColumn(), 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 72 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 1685 of file class.ilDB.php.
|
protected |
Initialize the database connection.
Reimplemented in ilDBMySQL, ilDBOracle, and ilDBPostgreSQL.
Definition at line 289 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 |
Definition at line 206 of file class.ilDB.php.
References setDBHost(), setDBName(), setDBPassword(), setDBPort(), and setDBUser().
|
protected |
Initialize the host connection (no specific database)
Definition at line 352 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 1453 of file class.ilDB.php.
References free(), handleError(), manipulateF(), and MDB2_PREPARE_MANIP.
Referenced by ilDBOracle\replace().
|
static |
Check error.
Definition at line 431 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 896 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 1207 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 1848 of file class.ilDB.php.
References quote(), and raisePearError().
ilDB::listTables | ( | ) |
Get all tables.
Definition at line 2001 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 416 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 1830 of file class.ilDB.php.
|
abstract |
Abstraction of lock table.
array | table definitions |
Reimplemented in ilDBOracle, ilDBMySQL, and ilDBPostgreSQL.
ilDB::logStatement | ( | $sql | ) |
Helper function, should usually not be called.
Definition at line 1317 of file class.ilDB.php.
References substr().
ilDB::lower | ( | $a_exp | ) |
Upper.
string | expression |
Definition at line 1818 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 1379 of file class.ilDB.php.
References handleError().
Referenced by manipulateF(), 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 1297 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 643 of file class.ilDB.php.
References $type, checkColumnDefinition(), handleError(), and raisePearError().
ilDB::nextId | ( | $a_table_name | ) |
Get next ID for an index.
Definition at line 1359 of file class.ilDB.php.
References handleError().
ilDB::now | ( | ) |
Reimplemented in ilDBMySQL, ilDBOracle, and ilDBPostgreSQL.
Definition at line 1734 of file class.ilDB.php.
ilDB::numRows | ( | $a_set | ) |
Fetch row as associative array from result set.
object | result set |
Definition at line 1665 of file class.ilDB.php.
ilDB::optimizeTable | ( | $a_table | ) |
Optimize Table.
Reimplemented in ilDBMySQL.
Definition at line 1938 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 1394 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 1409 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 1244 of file class.ilDB.php.
References $ilBench, and handleError().
Referenced by ilCourseItems\__getItemData(), ilCourseItems\__getLastPosition(), ilRbacReview\__getParentRoles(), ilCourseItems\__purgeDeleted(), ilCourseArchives\__read(), ilDBMySQL\addFulltextIndex(), ilRbacSystem\checkAccessOfUser(), ilCourseItems\cloneDependencies(), createDatabase(), ilDBMySQL\dropFulltextIndex(), ilRbacReview\getLinkedRolesOfRoleFolder(), ilRbacReview\getOperation(), ilRbacReview\getOperations(), ilRbacReview\getOperationsOnTypeString(), ilRbacReview\getRoleMailboxAddress(), getRow(), ilDBOracle\initConnection(), ilDBMySQL\initConnection(), ilRbacReview\isDeleted(), ilDBMySQL\isFulltextIndex(), ilDBMySQL\lockTables(), ilDBMySQL\optimizeTable(), ilRbacSystem\preloadRbacPaCache(), queryF(), ilParticipants\readSubscriberData(), ilParticipants\readSubscribers(), ilRbacReview\roleExists(), ilRbacReview\searchRolesByMailboxAddressList(), ilDBMySQL\setMaxAllowedPacket(), and ilDBMySQL\unlockTables().
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 1273 of file class.ilDB.php.
References $query, $t, query(), quote(), and raisePearError().
ilDB::quote | ( | $a_query, | |
$a_type = null |
|||
) |
Wrapper for quote method.
Deprecated, use prepare/prepareManip instead.
Definition at line 2022 of file class.ilDB.php.
References raisePearError().
Referenced by equals(), equalsNot(), ilTree\getPathFull(), ilDBOracle\like(), like(), manipulateF(), queryF(), ilDBOracle\replace(), ilRbacReview\searchRolesByMailboxAddressList(), and update().
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 2049 of file class.ilDB.php.
ilDB::raisePearError | ( | $a_message, | |
$a_level = "" |
|||
) |
Raise an error.
Definition at line 401 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 773 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 723 of file class.ilDB.php.
References $f, 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.
Definition at line 1589 of file class.ilDB.php.
References free(), handleError(), manipulateF(), and MDB2_PREPARE_MANIP.
ilDB::rollback | ( | ) |
Rollback a transaction.
Definition at line 2087 of file class.ilDB.php.
References $res, and handleError().
ilDB::setDBHost | ( | $a_host | ) |
Set database host.
string | database host |
Definition at line 121 of file class.ilDB.php.
Referenced by initFromIniFile().
ilDB::setDBName | ( | $a_name | ) |
Set database name.
string | database name |
Definition at line 161 of file class.ilDB.php.
Referenced by initFromIniFile().
ilDB::setDBPassword | ( | $a_password | ) |
Set database password.
string | database password |
Definition at line 141 of file class.ilDB.php.
Referenced by initFromIniFile().
ilDB::setDBPort | ( | $a_port | ) |
Set database port.
string | database port |
Definition at line 101 of file class.ilDB.php.
Referenced by initFromIniFile().
ilDB::setDBUser | ( | $a_user | ) |
Set database user.
string | database user |
Definition at line 81 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 1351 of file class.ilDB.php.
ilDB::substr | ( | $a_exp, | |
$a_pos = 1 , |
|||
$a_len = -1 |
|||
) |
Substring.
@return |
Definition at line 1791 of file class.ilDB.php.
Referenced by checkColumnName(), checkTableName(), dropTable(), logStatement(), and ilDBMySQL\setMaxAllowedPacket().
ilDB::supportsFulltext | ( | ) |
Reimplemented in ilDBMySQL, ilDBOracle, and ilDBPostgreSQL.
Definition at line 356 of file class.ilDB.php.
Referenced by addIndex().
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 1975 of file class.ilDB.php.
References MDB2\isError().
ilDB::tableExists | ( | $a_table | ) |
Check, whether a given table exists.
string | table name |
Definition at line 1954 of file class.ilDB.php.
References listTables().
ilDB::unixTimestamp | ( | ) |
Unix timestamp.
Reimplemented in ilDBOracle.
Definition at line 1930 of file class.ilDB.php.
|
abstract |
Unlock tables locked by previous lock table calls.
Reimplemented in ilDBOracle, ilDBMySQL, 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 1507 of file class.ilDB.php.
References free(), handleError(), manipulateF(), MDB2_PREPARE_MANIP, and quote().
ilDB::upper | ( | $a_exp | ) |
Upper.
string | expression |
Definition at line 1807 of file class.ilDB.php.
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.
const ilDB::LOCK_READ = 2 |
Definition at line 31 of file class.ilDB.php.
Referenced by ilDBMySQL\lockTables(), and ilDBOracle\lockTables().
const ilDB::LOCK_WRITE = 1 |
Definition at line 30 of file class.ilDB.php.
Referenced by ilGlossaryDefinition\create(), ilGlossaryDefinition\delete(), ilTree\deleteTree(), ilTree\insertNode(), ilDBMySQL\lockTables(), ilDBOracle\lockTables(), ilGlossaryDefinition\moveDown(), ilTree\moveTree(), ilGlossaryDefinition\moveUp(), ilTree\renumber(), and ilTree\saveSubTree().