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


Public Member Functions | |
| driver_installed () | |
| get_dbfamily () | |
| get_name () | |
| get_configuration_help () | |
| get_configuration_hints () | |
| diagnose () | |
| connect ($dbhost, $dbuser, $dbpass, $dbname, $prefix, array $dboptions=null) | |
| dispose () | |
| get_server_info () | |
| get_last_error () | |
| get_tables ($usecache=true) | |
| get_indexes ($table) | |
| get_columns ($table, $usecache=true) | |
| setup_is_unicodedb () | |
| change_database_structure ($sql) | |
| execute ($sql, array $params=null) | |
| get_record_sql ($sql, array $params=null, $strictness=IGNORE_MISSING) | |
| 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_null_from_clause () | |
| sql constructs | |
| sql_bitand ($int1, $int2) | |
| sql_bitnot ($int1) | |
| sql_bitor ($int1, $int2) | |
| sql_bitxor ($int1, $int2) | |
| sql_modulo ($int1, $int2) | |
| sql_cast_char2int ($fieldname, $text=false) | |
| sql_cast_char2real ($fieldname, $text=false) | |
| sql_like ($fieldname, $param, $casesensitive=true, $accentsensitive=true, $notlike=false, $escapechar= '\\') | |
| sql_concat () | |
| sql_concat_join ($separator="' '", $elements=array()) | |
| sql_position ($needle, $haystack) | |
| sql_isempty ($tablename, $fieldname, $nullablefield, $textfield) | |
| sql_empty () | |
| sql_order_by_text ($fieldname, $numchars=32) | |
| session_lock_supported () | |
| session locking | |
| get_session_lock ($rowid, $timeout) | |
| release_session_lock ($rowid) | |
Static Public Member Functions | |
| static | onespace2empty (&$item, $key=null) |
Protected Member Functions | |
| get_dbtype () | |
| get_dblibrary () | |
| query_start ($sql, array $params=null, $type, $extrainfo=null) | |
| query_end ($result, $stmt=null) | |
| is_min_version ($version) | |
| fix_table_names ($sql) | |
| allowed_param_types () | |
| parse_query ($sql) | |
| tweak_param_names ($sql, array $params) | |
| normalise_value ($column, $value) | |
| bind_params ($stmt, array $params=null, $tablename=null) | |
| free_descriptors ($descriptors) | |
| create_recordset ($stmt) | |
| bitwise_supported () | |
| begin_transaction () | |
| transactions | |
| commit_transaction () | |
| rollback_transaction () | |
Protected Attributes | |
| $oci = null | |
Native oci class representing moodle database interface.
One complete reference for PHP + OCI: http://www.oracle.com/technology/tech/php/underground-php-oracle-manual.html
Definition at line 40 of file oci_native_moodle_database.php.
| allowed_param_types | ( | ) | [protected] |
Returns supported query parameter types
Reimplemented from moodle_database.
Definition at line 320 of file oci_native_moodle_database.php.
| begin_transaction | ( | ) | [protected] |
transactions
Driver specific start of real database transaction, this can not be used directly in code.
Reimplemented from moodle_database.
Definition at line 1662 of file oci_native_moodle_database.php.
| bind_params | ( | $ | stmt, |
| array $ | params = null, |
||
| $ | tablename = null |
||
| ) | [protected] |
Definition at line 887 of file oci_native_moodle_database.php.


| bitwise_supported | ( | ) | [protected] |
Definition at line 1444 of file oci_native_moodle_database.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 875 of file oci_native_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 1671 of file oci_native_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 |
| dml_connection_exception | if error |
Reimplemented from moodle_database.
Definition at line 144 of file oci_native_moodle_database.php.

| create_recordset | ( | $ | stmt | ) | [protected] |
Definition at line 1067 of file oci_native_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 1418 of file oci_native_moodle_database.php.

| diagnose | ( | ) |
Diagnose database and tables, this function is used to verify database and driver settings, db engine types, etc.
Reimplemented from moodle_database.
Definition at line 125 of file oci_native_moodle_database.php.

| dispose | ( | ) |
Close database connection and release all resources and memory (especially circular memory references). Do NOT use connect() again, create a new instance if needed.
Reimplemented from moodle_database.
Definition at line 227 of file oci_native_moodle_database.php.
| driver_installed | ( | ) |
Detects if all needed PHP stuff installed. Note: can be used before connect()
Reimplemented from moodle_database.
Definition at line 58 of file oci_native_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 |
| dml_exception | if error |
Reimplemented from moodle_database.
Definition at line 987 of file oci_native_moodle_database.php.

| fix_table_names | ( | $ | sql | ) | [protected] |
Converts short table name {tablename} to real table name supporting temp tables ($this->unique_session_id based) if detected
| string | sql |
Reimplemented from moodle_database.
Definition at line 302 of file oci_native_moodle_database.php.
| free_descriptors | ( | $ | descriptors | ) | [protected] |
Definition at line 959 of file oci_native_moodle_database.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 469 of file oci_native_moodle_database.php.


Returns localised database configuration help. Note: can be used before connect()
Reimplemented from moodle_database.
Definition at line 106 of file oci_native_moodle_database.php.
Returns localised database description Note: can be used before connect()
Reimplemented from moodle_database.
Definition at line 115 of file oci_native_moodle_database.php.
| get_dbfamily | ( | ) |
Returns database family type - describes SQL dialect Note: can be used before connect()
Reimplemented from moodle_database.
Definition at line 70 of file oci_native_moodle_database.php.

| get_dblibrary | ( | ) | [protected] |
Returns general database library name Note: can be used before connect()
Reimplemented from moodle_database.
Definition at line 88 of file oci_native_moodle_database.php.
| get_dbtype | ( | ) | [protected] |
Returns more specific database driver type Note: can be used before connect()
Reimplemented from moodle_database.
Definition at line 79 of file oci_native_moodle_database.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 1127 of file oci_native_moodle_database.php.

| get_indexes | ( | $ | table | ) |
Return table indexes - everything lowercased
Reimplemented from moodle_database.
Definition at line 428 of file oci_native_moodle_database.php.

| get_last_error | ( | ) |
Returns last error reported by database engine.
Reimplemented from moodle_database.
Definition at line 328 of file oci_native_moodle_database.php.
| get_name | ( | ) |
Returns localised database type name Note: can be used before connect()
Reimplemented from moodle_database.
Definition at line 97 of file oci_native_moodle_database.php.
| get_record_sql | ( | $ | sql, |
| array $ | params = null, |
||
| $ | strictness = IGNORE_MISSING |
||
| ) |
Get a single database record as an object using a SQL statement.
The SQL statement should normally only return one record. It is recommended to use get_records_sql() if more matches possible!
| string | $sql | The SQL string you wish to be executed, should normally only return one record. |
| array | $params | array of sql parameters |
| int | $strictness | IGNORE_MISSING means compatible mode, false returned if record not found, debug message if more found; IGNORE_MULTIPLE means return first, ignore multiple records found(not recommended); MUST_EXIST means throw exception if no record or multiple records found |
| dml_exception | if error |
Reimplemented from moodle_database.
Definition at line 1019 of file oci_native_moodle_database.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 1085 of file oci_native_moodle_database.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 1051 of file oci_native_moodle_database.php.


| get_server_info | ( | ) |
Returns database server info array
Reimplemented from moodle_database.
Definition at line 275 of file oci_native_moodle_database.php.


| get_session_lock | ( | $ | rowid, |
| $ | timeout | ||
| ) |
Obtain session lock
| int | $rowid | id of the row with session record |
| int | $timeout | max allowed time to wait for the lock in seconds |
Reimplemented from moodle_database.
Definition at line 1619 of file oci_native_moodle_database.php.

| get_tables | ( | $ | usecache = true | ) |
Return tables in database WITHOUT current prefix
Reimplemented from moodle_database.
Definition at line 391 of file oci_native_moodle_database.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 1258 of file oci_native_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. |
| dml_exception | if error |
Reimplemented from moodle_database.
Definition at line 1229 of file oci_native_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 |
| dml_exception | if error |
Reimplemented from moodle_database.
Definition at line 1157 of file oci_native_moodle_database.php.


| is_min_version | ( | $ | version | ) | [protected] |
Definition at line 289 of file oci_native_moodle_database.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 673 of file oci_native_moodle_database.php.

| static onespace2empty | ( | &$ | item, |
| $ | key = null |
||
| ) | [static] |
This function is used to convert all the Oracle 1-space defaults to the empty string like a really DIRTY HACK to allow it to work better until all those NOT NULL DEFAULT '' fields will be out from Moodle.
| string | the string to be converted to '' (empty string) if it's ' ' (one space) |
| mixed | the key of the array in case we are using this function from array_walk, defaults to null for other (direct) uses |
Definition at line 974 of file oci_native_moodle_database.php.
| parse_query | ( | $ | sql | ) | [protected] |
Prepare the statement for execution
| dml_connection_exception |
| string | $sql |
Definition at line 349 of file oci_native_moodle_database.php.

| query_end | ( | $ | result, |
| $ | stmt = null |
||
| ) | [protected] |
Called immediately after each db query.
| mixed | db specific result |
Definition at line 255 of file oci_native_moodle_database.php.

| query_start | ( | $ | sql, |
| array $ | params = null, |
||
| $ | type, | ||
| $ | extrainfo = null |
||
| ) | [protected] |
Called before each db 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 244 of file oci_native_moodle_database.php.

| release_session_lock | ( | $ | rowid | ) |
Release session lock
| int | $rowid | id of the row with session record |
Reimplemented from moodle_database.
Definition at line 1639 of file oci_native_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 1683 of file oci_native_moodle_database.php.

session locking
Reimplemented from moodle_database.
Definition at line 1593 of file oci_native_moodle_database.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 1362 of file oci_native_moodle_database.php.

Is db in unicode mode?
Reimplemented from moodle_database.
Definition at line 854 of file oci_native_moodle_database.php.

| sql_bitand | ( | $ | int1, |
| $ | int2 | ||
| ) |
Returns the SQL text to be used in order to perform one bitwise AND operation between 2 integers.
NOTE: The SQL result is a number and can not be used directly in SQL condition, please compare it to some number to get a bool!!
| int | $int1 | first integer in the operation |
| int | $int2 | second integer in the operation |
Reimplemented from moodle_database.
Definition at line 1464 of file oci_native_moodle_database.php.

| sql_bitnot | ( | $ | int1 | ) |
Returns the SQL text to be used in order to perform one bitwise NOT operation with 1 integer.
| int | $int1 | integer in the operation |
Reimplemented from moodle_database.
Definition at line 1468 of file oci_native_moodle_database.php.
| sql_bitor | ( | $ | int1, |
| $ | int2 | ||
| ) |
Returns the SQL text to be used in order to perform one bitwise OR operation between 2 integers.
NOTE: The SQL result is a number and can not be used directly in SQL condition, please compare it to some number to get a bool!!
| int | $int1 | first integer in the operation |
| int | $int2 | second integer in the operation |
Reimplemented from moodle_database.
Definition at line 1472 of file oci_native_moodle_database.php.


| sql_bitxor | ( | $ | int1, |
| $ | int2 | ||
| ) |
Returns the SQL text to be used in order to perform one bitwise XOR operation between 2 integers.
NOTE: The SQL result is a number and can not be used directly in SQL condition, please compare it to some number to get a bool!!
| int | $int1 | first integer in the operation |
| int | $int2 | second integer in the operation |
Reimplemented from moodle_database.
Definition at line 1481 of file oci_native_moodle_database.php.

| sql_cast_char2int | ( | $ | fieldname, |
| $ | text = false |
||
| ) |
Returns the SQL to be used in order to CAST one CHAR column to INTEGER.
Be aware that the CHAR column you're trying to cast contains really int values or the RDBMS will throw an error!
| string | $fieldname | the name of the field to be casted |
| bool | $text | to specify if the original column is one TEXT (CLOB) column (true). Defaults to false. |
Reimplemented from moodle_database.
Definition at line 1502 of file oci_native_moodle_database.php.

| sql_cast_char2real | ( | $ | fieldname, |
| $ | text = false |
||
| ) |
Returns the SQL to be used in order to CAST one CHAR column to REAL number.
Be aware that the CHAR column you're trying to cast contains really numbers or the RDBMS will throw an error!
| string | $fieldname | the name of the field to be casted |
| bool | $text | to specify if the original column is one TEXT (CLOB) column (true). Defaults to false. |
Reimplemented from moodle_database.
Definition at line 1510 of file oci_native_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.
Definition at line 1549 of file oci_native_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.
Definition at line 1558 of file oci_native_moodle_database.php.
| sql_empty | ( | ) |
Returns the empty string char used by every supported DB. To be used when we are searching for that values in our queries. Only Oracle uses this for now (will be out, once we migrate to proper NULLs if that days arrives)
Reimplemented from moodle_database.
Definition at line 1584 of file oci_native_moodle_database.php.

| sql_isempty | ( | $ | tablename, |
| $ | fieldname, | ||
| $ | nullablefield, | ||
| $ | textfield | ||
| ) |
Returns the proper SQL to know if one field is empty.
Note that the function behavior strongly relies on the parameters passed describing the field so, please, be accurate when specifying them.
Also, note that this function is not suitable to look for fields having NULL contents at all. It's all for empty values!
This function should be applied in all the places where conditions of the type:
... AND fieldname = '';
are being used. Final result should be:
... AND ' . sql_isempty('tablename', 'fieldname', true/false, true/false);
(see parameters description below)
| string | $tablename | name of the table (without prefix). Not used for now but can be necessary in the future if we want to use some introspection using meta information against the DB. /// TODO /// |
| string | $fieldname | name of the field we are going to check |
| boolean | $nullablefield | to specify if the field us nullable (true) or no (false) in the DB |
| boolean | $textfield | to specify if it is a text (also called clob) field (true) or a varchar one (false) |
Reimplemented from moodle_database.
Definition at line 1576 of file oci_native_moodle_database.php.

| sql_like | ( | $ | fieldname, |
| $ | param, | ||
| $ | casesensitive = true, |
||
| $ | accentsensitive = true, |
||
| $ | notlike = false, |
||
| $ | escapechar = '\\' |
||
| ) |
Returns 'LIKE' part of a query.
| string | $fieldname | usually name of the table column |
| string | $param | usually bound query parameter (?, :named) |
| bool | $casesensitive | use case sensitive search |
| bool | $accensensitive | use accent sensitive search (not all databases support accent insensitive) |
| bool | $notlike | true means "NOT LIKE" |
| string | $escapechar | escape char for '' and '_' |
Reimplemented from moodle_database.
Definition at line 1529 of file oci_native_moodle_database.php.

| sql_modulo | ( | $ | int1, |
| $ | int2 | ||
| ) |
Returns the SQL text to be used in order to perform module '' operation - remainder after division
| integer | int1 first integer in the operation |
| integer | int2 second integer in the operation |
Reimplemented from moodle_database.
Definition at line 1498 of file oci_native_moodle_database.php.
sql constructs
Returns the FROM clause required by some DBs in all SELECT statements.
To be used in queries not having FROM clause to provide cross_db Most DBs don't need it, hence the default is ''
Reimplemented from moodle_database.
Definition at line 1439 of file oci_native_moodle_database.php.
| sql_order_by_text | ( | $ | fieldname, |
| $ | numchars = 32 |
||
| ) |
Returns the SQL text to be used to order by one TEXT (clob) column, because some RDBMS doesn't support direct ordering of such fields.
Note that the use or queries being ordered by TEXT columns must be minimised, because it's really slooooooow.
| string | $fieldname | the name of the TEXT field we need to order by |
| string | $numchars | of chars to use for the ordering (defaults to 32) |
Reimplemented from moodle_database.
Definition at line 1588 of file oci_native_moodle_database.php.
| sql_position | ( | $ | needle, |
| $ | haystack | ||
| ) |
Returns the SQL for returning searching one string for the location of another.
Reimplemented from moodle_database.
Definition at line 1572 of file oci_native_moodle_database.php.
| tweak_param_names | ( | $ | sql, |
| array $ | params | ||
| ) | [protected] |
Make sure there are no reserved words in param names...
| string | $sql | |
| array | $params |
Definition at line 363 of file oci_native_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 |
| dml_exception | if error |
Reimplemented from moodle_database.
Definition at line 1332 of file oci_native_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 |
| dml_exception | if error |
Reimplemented from moodle_database.
Definition at line 1283 of file oci_native_moodle_database.php.


$oci = null [protected] |
Definition at line 42 of file oci_native_moodle_database.php.