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


Public Member Functions | |
| __construct ($external=false) | |
| connect ($dbhost, $dbuser, $dbpass, $dbname, $prefix, array $dboptions=null) | |
| get_name () | |
| get_configuration_help () | |
| get_configuration_hints () | |
| get_server_info () | |
| get_last_error () | |
| change_database_structure ($sql) | |
| delete_records_select ($table, $select, array $params=null) | |
| execute ($sql, array $params=null) | |
| get_recordset_sql ($sql, array $params=null, $limitfrom=0, $limitnum=0) | |
| get_fieldset_sql ($sql, array $params=null) | |
| get_records_sql ($sql, array $params=null, $limitfrom=0, $limitnum=0) | |
| insert_record_raw ($table, $params, $returnid=true, $bulk=false, $customsequence=false) | |
| insert_record ($table, $dataobject, $returnid=true, $bulk=false) | |
| update_record_raw ($table, $params, $bulk=false) | |
| update_record ($table, $dataobject, $bulk=false) | |
| set_field_select ($table, $newfield, $newvalue, $select, array $params=null) | |
| sql_concat () | |
| sql_concat_join ($separator="' '", $elements=array()) | |
| import_record ($table, $dataobject) | |
Protected Member Functions | |
| get_dsn () | |
| get_pdooptions () | |
| configure_dbconnection () | |
| get_dblibrary () | |
| allowed_param_types () | |
| debug_query ($sql, $params=null) | |
| create_recordset ($sth) | |
| begin_transaction () | |
| commit_transaction () | |
| rollback_transaction () | |
| query_start ($sql, array $params=null, $type, $extrainfo=null) | |
Protected Attributes | |
| $pdb | |
| $lastError = null | |
Experimental pdo database class
Definition at line 36 of file pdo_moodle_database.php.
| __construct | ( | $ | external = false | ) |
Constructor - instantiates the database, specifying if it's external (connect to other systems) or no (Moodle DB) note this has effect to decide if prefix checks must be performed or no
| bool | true means external database used |
Reimplemented from moodle_database.
Definition at line 46 of file pdo_moodle_database.php.
| allowed_param_types | ( | ) | [protected] |
Returns supported query parameter types
Reimplemented from moodle_database.
Definition at line 158 of file pdo_moodle_database.php.
| begin_transaction | ( | ) | [protected] |
Driver specific start of real database transaction, this can not be used directly in code.
Reimplemented from moodle_database.
Definition at line 544 of file pdo_moodle_database.php.

| change_database_structure | ( | $ | sql | ) |
Do NOT use in code, to be used by database_manager only!
| string | $sql | query |
Reimplemented from moodle_database.
Definition at line 188 of file pdo_moodle_database.php.

| commit_transaction | ( | ) | [protected] |
Driver specific commit of real database transaction, this can not be used directly in code.
Reimplemented from moodle_database.
Definition at line 554 of file pdo_moodle_database.php.

| configure_dbconnection | ( | ) | [protected] |
TODO: not needed preconfigure_dbconnection() stuff for PDO drivers?
Reimplemented in sqlite3_pdo_moodle_database.
Definition at line 99 of file pdo_moodle_database.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 |
Reimplemented from moodle_database.
Definition at line 61 of file pdo_moodle_database.php.

| create_recordset | ( | $ | sth | ) | [protected] |
Factory method that creates a recordset for return by a query. The generic pdo_moodle_recordset class should fit most cases, but pdo_moodle_database subclasses can override this method to return a subclass of pdo_moodle_recordset.
| object | $sth | instance of PDOStatement |
Definition at line 218 of file pdo_moodle_database.php.

| debug_query | ( | $ | sql, |
| $ | params = null |
||
| ) | [protected] |
Function to print/save/ignore debugging messages related to SQL queries.
Definition at line 173 of file pdo_moodle_database.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 203 of file pdo_moodle_database.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 |
Reimplemented from moodle_database.
Definition at line 229 of file pdo_moodle_database.php.


Returns localised database configuration help. Note: can be used before connect()
Reimplemented from moodle_database.
Definition at line 126 of file pdo_moodle_database.php.

Returns localised database description Note: can be used before connect()
Reimplemented from moodle_database.
Definition at line 135 of file pdo_moodle_database.php.

| get_dblibrary | ( | ) | [protected] |
Returns general database library name Note: can be used before connect()
Reimplemented from moodle_database.
Definition at line 108 of file pdo_moodle_database.php.
| get_dsn | ( | ) | [abstract, protected] |
Returns the driver-dependent DSN for PDO based on members stored by connect. Must be called after connect (or after $dbname, $dbhost, etc. members have been set).
Reimplemented in sqlite3_pdo_moodle_database.

| get_fieldset_sql | ( | $ | sql, |
| array $ | params = null |
||
| ) |
Selects rows and return values of first column as array.
| string | $sql | The SQL query |
| array | $params | array of sql parameters |
Reimplemented from moodle_database.
Definition at line 289 of file pdo_moodle_database.php.

| get_last_error | ( | ) |
Returns last error reported by database engine.
Reimplemented from moodle_database.
Definition at line 166 of file pdo_moodle_database.php.
| get_name | ( | ) |
Returns localised database type name Note: can be used before connect()
Reimplemented from moodle_database.
Definition at line 117 of file pdo_moodle_database.php.

| get_pdooptions | ( | ) | [protected] |
Returns the driver-dependent connection attributes for PDO based on members stored by connect. Must be called after $dbname, $dbhost, etc. members have been set.
Definition at line 95 of file pdo_moodle_database.php.

| get_records_sql | ( | $ | sql, |
| array $ | params = null, |
||
| $ | limitfrom = 0, |
||
| $ | limitnum = 0 |
||
| ) |
Get a number of records as an array of objects.
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). |
Reimplemented from moodle_database.
Definition at line 316 of file pdo_moodle_database.php.

| get_recordset_sql | ( | $ | sql, |
| array $ | params = null, |
||
| $ | limitfrom = 0, |
||
| $ | limitnum = 0 |
||
| ) |
Get a number of records as an moodle_recordset. $sql must be a complete SQL query. 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). |
Reimplemented from moodle_database.
Definition at line 261 of file pdo_moodle_database.php.


| get_server_info | ( | ) |
Returns database server info array
Reimplemented from moodle_database.
Definition at line 143 of file pdo_moodle_database.php.
| import_record | ( | $ | table, |
| $ | dataobject | ||
| ) |
Import a record into a table, id field is required. Basic safety checks only. Lobs are supported.
| string | $table | name of database table to be inserted into |
| mixed | $dataobject | object or array with fields in the record |
Reimplemented from moodle_database.
Definition at line 583 of file pdo_moodle_database.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. |
| bool | $bulk | true means repeated inserts expected |
Reimplemented from moodle_database.
Definition at line 390 of file pdo_moodle_database.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 |
Reimplemented from moodle_database.
Definition at line 344 of file pdo_moodle_database.php.


| query_start | ( | $ | sql, |
| array $ | params = null, |
||
| $ | type, | ||
| $ | extrainfo = null |
||
| ) | [protected] |
Called before each db query.
Overridden to ensure $this->lastErorr is reset each query
| string | $sql | |
| array | array of parameters | |
| int | $type | type of query |
| mixed | $extrainfo | driver specific extra information |
Reimplemented from moodle_database.
Definition at line 609 of file pdo_moodle_database.php.

| rollback_transaction | ( | ) | [protected] |
Driver specific abort of real database transaction, this can not be used directly in code.
Reimplemented from moodle_database.
Definition at line 565 of file pdo_moodle_database.php.

| set_field_select | ( | $ | table, |
| $ | newfield, | ||
| $ | newvalue, | ||
| $ | select, | ||
| array $ | params = null |
||
| ) |
Set a single field in every table row where the select statement evaluates to true.
| 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 |
Reimplemented from moodle_database.
Definition at line 501 of file pdo_moodle_database.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.
Reimplemented in sqlite3_pdo_moodle_database.
Definition at line 536 of file pdo_moodle_database.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.
Reimplemented in sqlite3_pdo_moodle_database.
Definition at line 540 of file pdo_moodle_database.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 |
Reimplemented from moodle_database.
Definition at line 472 of file pdo_moodle_database.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 |
Reimplemented from moodle_database.
Definition at line 435 of file pdo_moodle_database.php.


$lastError = null [protected] |
Definition at line 39 of file pdo_moodle_database.php.
$pdb [protected] |
Definition at line 38 of file pdo_moodle_database.php.