|
Moodle
2.2.1
http://www.collinsharper.com
|


Public Member Functions | |
| public_fix_table_names ($sql) | |
| driver_installed () | |
| get_dbfamily () | |
| get_name () | |
| get_configuration_help () | |
| get_configuration_hints () | |
| connect ($dbhost, $dbuser, $dbpass, $dbname, $prefix, array $dboptions=null) | |
| get_server_info () | |
| get_last_error () | |
| get_tables ($usecache=true) | |
| get_indexes ($table) | |
| get_columns ($table, $usecache=true) | |
| set_debug ($state) | |
| get_debug () | |
| set_logging ($state) | |
| change_database_structure ($sql) | |
| execute ($sql, array $params=null) | |
| get_recordset_sql ($sql, array $params=null, $limitfrom=0, $limitnum=0) | |
| get_records_sql ($sql, array $params=null, $limitfrom=0, $limitnum=0) | |
| get_fieldset_sql ($sql, array $params=null) | |
| insert_record_raw ($table, $params, $returnid=true, $bulk=false, $customsequence=false) | |
| insert_record ($table, $dataobject, $returnid=true, $bulk=false) | |
| import_record ($table, $dataobject) | |
| update_record_raw ($table, $params, $bulk=false) | |
| update_record ($table, $dataobject, $bulk=false) | |
| set_field_select ($table, $newfield, $newvalue, $select, array $params=null) | |
| delete_records_select ($table, $select, array $params=null) | |
| sql_concat () | |
| sql_concat_join ($separator="' '", $elements=array()) | |
| sql_substr ($expr, $start, $length=false) | |
| begin_transaction () | |
| commit_transaction () | |
| rollback_transaction () | |
Protected Member Functions | |
| get_dbtype () | |
| get_dblibrary () | |
| allowed_param_types () | |
| normalise_value ($column, $value) | |
Protected Attributes | |
| $prefix = 'mdl_' | |
This class is not a proper subclass of moodle_database. It is intended to be used only in unit tests, in order to gain access to the protected methods of moodle_database, and unit test them.
Definition at line 4465 of file testdml.php.
| allowed_param_types | ( | ) | [protected] |
Returns supported query parameter types
Reimplemented from moodle_database.
Definition at line 4481 of file testdml.php.
Driver specific start of real database transaction, this can not be used directly in code.
Reimplemented from moodle_database.
Definition at line 4505 of file testdml.php.
| change_database_structure | ( | $ | sql | ) |
Do NOT use in code, to be used by database_manager only!
| string | $sql | query |
| dml_exception | if error |
Reimplemented from moodle_database.
Definition at line 4490 of file testdml.php.
Driver specific commit of real database transaction, this can not be used directly in code.
Reimplemented from moodle_database.
Definition at line 4506 of file testdml.php.
Connect to db Must be called before other methods.
| string | $dbhost | |
| string | $dbuser | |
| string | $dbpass | |
| string | $dbname | |
| mixed | $prefix | string means moodle db prefix, false used for external databases where prefix not used |
| array | $dboptions | driver specific options |
| dml_connection_exception | if error |
Reimplemented from moodle_database.
Definition at line 4479 of file testdml.php.
| delete_records_select | ( | $ | table, |
| $ | select, | ||
| array $ | params = null |
||
| ) |
Delete one or more records from a table which match a particular WHERE clause.
| string | $table | The database table to be checked against. |
| string | $select | A fragment of SQL to be used in a where clause in the SQL call (used to define the selection criteria). |
| array | $params | array of sql parameters |
| dml_exception | if error |
Reimplemented from moodle_database.
Definition at line 4501 of file testdml.php.
| driver_installed | ( | ) |
Detects if all needed PHP stuff installed. Note: can be used before connect()
Reimplemented from moodle_database.
Definition at line 4472 of file testdml.php.
Execute general sql query. Should be used only when no other method suitable. Do NOT use this to make changes in db structure, use database_manager::execute_sql() instead!
| string | $sql | query |
| array | $params | query parameters |
| dml_exception | if error |
Reimplemented from moodle_database.
Definition at line 4491 of file testdml.php.
| get_columns | ( | $ | table, |
| $ | usecache = true |
||
| ) |
Returns detailed information about columns in table. This information is cached internally.
| string | $table | name |
| bool | $usecache |
Reimplemented from moodle_database.
Definition at line 4485 of file testdml.php.
Returns localised database configuration help. Note: can be used before connect()
Reimplemented from moodle_database.
Definition at line 4477 of file testdml.php.
Returns localised database description Note: can be used before connect()
Reimplemented from moodle_database.
Definition at line 4478 of file testdml.php.
| get_dbfamily | ( | ) |
Returns database family type - describes SQL dialect Note: can be used before connect()
Reimplemented from moodle_database.
Definition at line 4473 of file testdml.php.
| get_dblibrary | ( | ) | [protected] |
Returns general database library name Note: can be used before connect()
Reimplemented from moodle_database.
Definition at line 4475 of file testdml.php.
| get_dbtype | ( | ) | [protected] |
Returns more specific database driver type Note: can be used before connect()
Reimplemented from moodle_database.
Definition at line 4474 of file testdml.php.
| get_debug | ( | ) |
Returns debug status
Reimplemented from moodle_database.
Definition at line 4488 of file testdml.php.
| get_fieldset_sql | ( | $ | sql, |
| array $ | params = null |
||
| ) |
Selects records and return values (first field) as an array using a SQL statement.
| string | $sql | The SQL query |
| array | $params | array of sql parameters |
| dml_exception | if error |
Reimplemented from moodle_database.
Definition at line 4494 of file testdml.php.
| get_indexes | ( | $ | table | ) |
Return table indexes - everything lowercased
Reimplemented from moodle_database.
Definition at line 4484 of file testdml.php.
| get_last_error | ( | ) |
Returns last error reported by database engine.
Reimplemented from moodle_database.
Definition at line 4482 of file testdml.php.
| get_name | ( | ) |
Returns localised database type name Note: can be used before connect()
Reimplemented from moodle_database.
Definition at line 4476 of file testdml.php.
| get_records_sql | ( | $ | sql, |
| array $ | params = null, |
||
| $ | limitfrom = 0, |
||
| $ | limitnum = 0 |
||
| ) |
Get a number of records as an array of objects using a SQL statement.
Return value as for
| string | $sql | the SQL select query to execute. The first column of this SELECT statement must be a unique value (usually the 'id' field), as it will be used as the key of the returned array. |
| array | $params | array of sql parameters |
| int | $limitfrom | return a subset of records, starting at this point (optional, required if $limitnum is set). |
| int | $limitnum | return a subset comprising this many records (optional, required if $limitfrom is set). |
| dml_exception | if error |
Reimplemented from moodle_database.
Definition at line 4493 of file testdml.php.
| get_recordset_sql | ( | $ | sql, |
| array $ | params = null, |
||
| $ | limitfrom = 0, |
||
| $ | limitnum = 0 |
||
| ) |
Get a number of records as a moodle_recordset using a SQL statement.
Since this method is a little less readable, use of it should be restricted to code where it's possible there might be large datasets being returned. For known small datasets use get_records_sql - it leads to simpler code.
The return type is as for
| string | $sql | the SQL select query to execute. |
| array | $params | array of sql parameters |
| int | $limitfrom | return a subset of records, starting at this point (optional, required if $limitnum is set). |
| int | $limitnum | return a subset comprising this many records (optional, required if $limitfrom is set). |
| dml_exception | if error |
Reimplemented from moodle_database.
Definition at line 4492 of file testdml.php.
| get_server_info | ( | ) |
Returns database server info array
Reimplemented from moodle_database.
Definition at line 4480 of file testdml.php.
| get_tables | ( | $ | usecache = true | ) |
Return tables in database WITHOUT current prefix
Reimplemented from moodle_database.
Definition at line 4483 of file testdml.php.
| import_record | ( | $ | table, |
| $ | dataobject | ||
| ) |
Import a record into a table, id field is required. Safety checks are NOT carried out. Lobs are supported.
| string | $table | name of database table to be inserted into |
| object | $dataobject | A data object with values for one or more fields in the record |
| dml_exception | if error |
Reimplemented from moodle_database.
Definition at line 4497 of file testdml.php.
| insert_record | ( | $ | table, |
| $ | dataobject, | ||
| $ | returnid = true, |
||
| $ | bulk = false |
||
| ) |
Insert a record into a table and return the "id" field if required.
Some conversions and safety checks are carried out. Lobs are supported. If the return ID isn't required, then this just reports success as true/false. $data is an object containing needed data
| string | $table | The database table to be inserted into |
| object | $data | A data object with values for one or more fields in the record |
| bool | $returnid | Should the id of the newly created record entry be returned? If this option is not requested then true/false is returned. |
| dml_exception | if error |
Reimplemented from moodle_database.
Definition at line 4496 of file testdml.php.
| insert_record_raw | ( | $ | table, |
| $ | params, | ||
| $ | returnid = true, |
||
| $ | bulk = false, |
||
| $ | customsequence = false |
||
| ) |
Insert new record into database, as fast as possible, no safety checks, lobs not supported.
| string | $table | name |
| mixed | $params | data record as object or array |
| bool | $returnit | return it of inserted record |
| bool | $bulk | true means repeated inserts expected |
| bool | $customsequence | true if 'id' included in $params, disables $returnid |
| dml_exception | if error |
Reimplemented from moodle_database.
Definition at line 4495 of file testdml.php.
| normalise_value | ( | $ | column, |
| $ | value | ||
| ) | [protected] |
Normalise values based in RDBMS dependencies (booleans, LOBs...)
| database_column_info | $column | column metadata corresponding with the value we are going to normalise |
| mixed | $value | value we are going to normalise |
Reimplemented from moodle_database.
Definition at line 4486 of file testdml.php.
| public_fix_table_names | ( | $ | sql | ) |
Driver specific abort of real database transaction, this can not be used directly in code.
Reimplemented from moodle_database.
Definition at line 4507 of file testdml.php.
| set_debug | ( | $ | state | ) |
Enable/disable very detailed debugging
| bool | $state |
Reimplemented from moodle_database.
Definition at line 4487 of file testdml.php.
| set_field_select | ( | $ | table, |
| $ | newfield, | ||
| $ | newvalue, | ||
| $ | select, | ||
| array $ | params = null |
||
| ) |
Set a single field in every table record which match a particular WHERE clause.
| string | $table | The database table to be checked against. |
| string | $newfield | the field to set. |
| string | $newvalue | the value to set the field to. |
| string | $select | A fragment of SQL to be used in a where clause in the SQL call. |
| array | $params | array of sql parameters |
| dml_exception | if error |
Reimplemented from moodle_database.
Definition at line 4500 of file testdml.php.
| set_logging | ( | $ | state | ) |
Enable/disable detailed sql logging
| bool | $state |
Reimplemented from moodle_database.
Definition at line 4489 of file testdml.php.
| sql_concat | ( | ) |
Returns the proper SQL to do CONCAT between the elements passed Can take many parameters
This function accepts variable number of string parameters.
Reimplemented from moodle_database.
Definition at line 4502 of file testdml.php.
| sql_concat_join | ( | $ | separator = "' '", |
| $ | elements = array() |
||
| ) |
Returns the proper SQL to do CONCAT between the elements passed with a given separator
| string | $separator | |
| array | $elements |
Reimplemented from moodle_database.
Definition at line 4503 of file testdml.php.
| sql_substr | ( | $ | expr, |
| $ | start, | ||
| $ | length = false |
||
| ) |
Returns the proper substr() SQL text used to extract substrings from DB NOTE: this was originally returning only function name
| string | $expr | some string field, no aggregates |
| mixed | $start | integer or expression evaluating to int (1 based value; first char has index 1) |
| mixed | $length | optional integer or expression evaluating to int |
Reimplemented from moodle_database.
Definition at line 4504 of file testdml.php.
| update_record | ( | $ | table, |
| $ | dataobject, | ||
| $ | bulk = false |
||
| ) |
Update a record in a table
$dataobject is an object containing needed data Relies on $dataobject having a variable "id" to specify the record to update
| string | $table | The database table to be checked against. |
| object | $dataobject | An object with contents equal to fieldname=>fieldvalue. Must have an entry for 'id' to map to the table specified. |
| bool | true means repeated updates expected |
| dml_exception | if error |
Reimplemented from moodle_database.
Definition at line 4499 of file testdml.php.
| update_record_raw | ( | $ | table, |
| $ | params, | ||
| $ | bulk = false |
||
| ) |
Update record in database, as fast as possible, no safety checks, lobs not supported.
| string | $table | name |
| mixed | $params | data record as object or array |
| bool | true means repeated updates expected |
| dml_exception | if error |
Reimplemented from moodle_database.
Definition at line 4498 of file testdml.php.
$prefix = 'mdl_' [protected] |
Reimplemented from moodle_database.
Definition at line 4466 of file testdml.php.