MDL-30972 Documentation : clarified phpdocs for main public APIs in DML layer and touched up on some drivers

This commit is contained in:
Aparup Banerjee 2012-01-19 10:15:11 +08:00
parent baa5cd8240
commit 6df260107c
12 changed files with 495 additions and 417 deletions

View File

@ -20,7 +20,7 @@
* Database column information.
*
* @package core
* @subpackage dml
* @category dml
* @copyright 2008 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@ -28,18 +28,27 @@
defined('MOODLE_INTERNAL') || die();
/**
* Detail database field information.
* Based on ADOFieldObject.
* Detailed database field information.
*
* It is based on the adodb library's ADOFieldObject object.
* 'column' does mean 'the field' here.
*
* @package core
* @category database
* @copyright 2008 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class database_column_info {
/**
* Name of column - lowercase
* Name of column - lowercase.
* @var string
*/
public $name;
/**
* Driver dependent native data type
* Not standardised - used to find meta_type
* Driver dependent native data type.
* Not standardised, its used to find meta_type.
* @var string
*/
public $type;
@ -51,6 +60,7 @@ class database_column_info {
* float - digits left from floating point
* boolean - 1
* enums - null
* @var int
*/
public $max_length;
@ -58,6 +68,7 @@ class database_column_info {
* Scale
* float - decimal points
* other - null
* @var int
*/
public $scale;
@ -67,54 +78,63 @@ class database_column_info {
*
* For performance reasons this field is optional!
* You can use DDL sql_generator::getCheckConstraintsFromDB() if needed.
* @var string
*/
public $enums;
/**
* True if not null, false otherwise
* @var bool
*/
public $not_null;
/**
* True if column is primary key.
* (usually 'id').
* @var bool
*/
public $primary_key;
/**
* True if filed autoincrementing
* (usually 'id' only)
* @var bool
*/
public $auto_increment;
/**
* True if binary
* @var bool
*/
public $binary;
/**
* True if integer unsigned, false if signed.
* Null for other types
* @var integer
*/
public $unsigned;
/**
* True if default value defined
* True if the default value is defined.
* @var bool
*/
public $has_default;
/**
* Default value if defined
* The default value (if defined).
* @var string
*/
public $default_value;
/**
* True if field values unique, false if not
* True if field values are unique, false if not.
* @var bool
*/
public $unique;
/**
* Standardised one character column type, uppercase
* Standardised one character column type, uppercased and enumerated as follows:
* R - counter (integer primary key)
* I - integers
* N - numbers (floats)
@ -124,12 +144,13 @@ class database_column_info {
* L - boolean (1 bit)
* T - timestamp - unsupported
* D - date - unsupported
* @var string
*/
public $meta_type;
/**
* Constructor
* @param $data mixed object or array with properties
* @param mixed $data object or array with properties
*/
public function __construct($data) {
foreach ($data as $key=>$value) {

File diff suppressed because it is too large Load Diff

View File

@ -20,7 +20,7 @@
* Abstract recordset.
*
* @package core
* @subpackage dml
* @category dml
* @copyright 2008 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

View File

@ -36,7 +36,7 @@
* databases like postgres need this, because they don't lack any temp functionality.
*
* @package core
* @subpackage dml
* @category dml
* @copyright 2009 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@ -45,13 +45,16 @@ defined('MOODLE_INTERNAL') || die();
class moodle_temptables {
protected $mdb; // circular reference, to be able to use DB facilities here if needed
protected $prefix; // prefix to be used for all the DB objects
protected $temptables; // simple array of moodle, not prefixed 'tablename' => DB, final (prefixed) 'tablename'
/** @var circular reference, to be able to use DB facilities here if needed */
protected $mdb;
/** @var prefix to be used for all the DB objects */
protected $prefix;
/** @var simple array of moodle, not prefixed 'tablename' => DB, final (prefixed) 'tablename' */
protected $temptables;
/**
* Creates new moodle_temptables instance
* @param object moodle_database instance
* @param moodle_database An instance of moodle_database.
*/
public function __construct($mdb) {
$this->mdb = $mdb;

View File

@ -20,7 +20,7 @@
* Delegated database transaction support.
*
* @package core
* @subpackage dml
* @category dml
* @copyright 2009 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@ -29,9 +29,16 @@ defined('MOODLE_INTERNAL') || die();
/**
* Delegated transaction class.
*
* @package core
* @category dml
* @copyright 2009 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class moodle_transaction {
/** @var array The debug_backtrace() returned array.*/
private $start_backtrace;
/**@var moodle_database The moodle_database instance.*/
private $database = null;
/**
@ -66,7 +73,7 @@ class moodle_transaction {
* Mark transaction as disposed, no more
* commits and rollbacks allowed.
* To be used only from moodle_database class
* @return unknown_type
* @return null
*/
public function dispose() {
return $this->database = null;

View File

@ -115,10 +115,10 @@ class mssql_native_moodle_database extends moodle_database {
/**
* Connect to db
* Must be called before other methods.
* @param string $dbhost
* @param string $dbuser
* @param string $dbpass
* @param string $dbname
* @param string $dbhost The database host.
* @param string $dbuser The database username.
* @param string $dbpass The database username's password.
* @param string $dbname The name of the database being connected to.
* @param mixed $prefix string means moodle db prefix, false used for external databases where prefix not used
* @param array $dboptions driver specific options
* @return bool true
@ -257,7 +257,7 @@ class mssql_native_moodle_database extends moodle_database {
/**
* Returns database server info array
* @return array
* @return array Array containing 'description' and 'version' info
*/
public function get_server_info() {
static $info;
@ -311,7 +311,7 @@ class mssql_native_moodle_database extends moodle_database {
/**
* Returns supported query parameter types
* @return int bitmask
* @return int bitmask of accepted SQL_PARAMS_*
*/
protected function allowed_param_types() {
return SQL_PARAMS_QM; // Not really, but emulated, see emulate_bound_params()
@ -327,6 +327,7 @@ class mssql_native_moodle_database extends moodle_database {
/**
* Return tables in database WITHOUT current prefix
* @param bool $usecache if true, returns list of cached tables.
* @return array of table names in lowercase and without prefix
*/
public function get_tables($usecache=true) {
@ -360,8 +361,9 @@ class mssql_native_moodle_database extends moodle_database {
}
/**
* Return table indexes - everything lowercased
* @return array of arrays
* Return table indexes - everything lowercased.
* @param string $table The table we want to get indexes from.
* @return array An associative array of indexes containing 'unique' flag and 'columns' being indexed
*/
public function get_indexes($table) {
$indexes = array();
@ -503,7 +505,7 @@ class mssql_native_moodle_database extends moodle_database {
}
/**
* Normalise values based in RDBMS dependencies (booleans, LOBs...)
* Normalise values based on varying RDBMS's dependencies (booleans, LOBs...)
*
* @param database_column_info $column column metadata corresponding with the value we are going to normalise
* @param mixed $value value we are going to normalise
@ -594,7 +596,7 @@ class mssql_native_moodle_database extends moodle_database {
* Do NOT use in code, to be used by database_manager only!
* @param string $sql query
* @return bool true
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function change_database_structure($sql) {
$this->reset_caches();
@ -652,7 +654,7 @@ class mssql_native_moodle_database extends moodle_database {
* @param string $sql query
* @param array $params query parameters
* @return bool true
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function execute($sql, array $params=null) {
@ -685,7 +687,7 @@ class mssql_native_moodle_database extends moodle_database {
* @param int $limitfrom return a subset of records, starting at this point (optional, required if $limitnum is set).
* @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set).
* @return moodle_recordset instance
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function get_recordset_sql($sql, array $params=null, $limitfrom=0, $limitnum=0) {
$limitfrom = (int)$limitfrom;
@ -733,7 +735,7 @@ class mssql_native_moodle_database extends moodle_database {
* @param int $limitfrom return a subset of records, starting at this point (optional, required if $limitnum is set).
* @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set).
* @return array of objects, or empty array if no records were found
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function get_records_sql($sql, array $params=null, $limitfrom=0, $limitnum=0) {
@ -760,7 +762,7 @@ class mssql_native_moodle_database extends moodle_database {
* @param string $sql The SQL query
* @param array $params array of sql parameters
* @return array of values
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function get_fieldset_sql($sql, array $params=null) {
@ -784,7 +786,7 @@ class mssql_native_moodle_database extends moodle_database {
* @param bool $bulk true means repeated inserts expected
* @param bool $customsequence true if 'id' included in $params, disables $returnid
* @return bool|int true or new id
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function insert_record_raw($table, $params, $returnid=true, $bulk=false, $customsequence=false) {
if (!is_array($params)) {
@ -864,7 +866,7 @@ class mssql_native_moodle_database extends moodle_database {
* @param object $data A data object with values for one or more fields in the record
* @param bool $returnid Should the id of the newly created record entry be returned? If this option is not requested then true/false is returned.
* @return bool|int true or new id
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function insert_record($table, $dataobject, $returnid=true, $bulk=false) {
$dataobject = (array)$dataobject;
@ -893,7 +895,7 @@ class mssql_native_moodle_database extends moodle_database {
* @param string $table name of database table to be inserted into
* @param object $dataobject A data object with values for one or more fields in the record
* @return bool true
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function import_record($table, $dataobject) {
$dataobject = (array)$dataobject;
@ -920,7 +922,7 @@ class mssql_native_moodle_database extends moodle_database {
* @param mixed $params data record as object or array
* @param bool true means repeated updates expected
* @return bool true
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function update_record_raw($table, $params, $bulk=false) {
$params = (array)$params;
@ -967,7 +969,7 @@ class mssql_native_moodle_database extends moodle_database {
* @param object $dataobject An object with contents equal to fieldname=>fieldvalue. Must have an entry for 'id' to map to the table specified.
* @param bool true means repeated updates expected
* @return bool true
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function update_record($table, $dataobject, $bulk=false) {
$dataobject = (array)$dataobject;
@ -995,7 +997,7 @@ class mssql_native_moodle_database extends moodle_database {
* @param string $select A fragment of SQL to be used in a where clause in the SQL call.
* @param array $params array of sql parameters
* @return bool true
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function set_field_select($table, $newfield, $newvalue, $select, array $params=null) {
@ -1042,7 +1044,7 @@ class mssql_native_moodle_database extends moodle_database {
* @param string $select A fragment of SQL to be used in a where clause in the SQL call (used to define the selection criteria).
* @param array $params array of sql parameters
* @return bool true
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function delete_records_select($table, $select, array $params=null) {

View File

@ -47,7 +47,7 @@ class mysqli_native_moodle_database extends moodle_database {
* @param string $dbpass
* @param string $dbname
* @return bool success
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function create_database($dbhost, $dbuser, $dbpass, $dbname, array $dboptions=null) {
$driverstatus = $this->driver_installed();
@ -258,10 +258,10 @@ class mysqli_native_moodle_database extends moodle_database {
/**
* Connect to db
* Must be called before other methods.
* @param string $dbhost
* @param string $dbuser
* @param string $dbpass
* @param string $dbname
* @param string $dbhost The database host.
* @param string $dbuser The database username.
* @param string $dbpass The database username's password.
* @param string $dbname The name of the database being connected to.e
* @param mixed $prefix string means moodle db prefix, false used for external databases where prefix not used
* @param array $dboptions driver specific options
* @return bool success
@ -340,7 +340,7 @@ class mysqli_native_moodle_database extends moodle_database {
/**
* Returns database server info array
* @return array
* @return array Array containing 'description' and 'version' info
*/
public function get_server_info() {
return array('description'=>$this->mysqli->server_info, 'version'=>$this->mysqli->server_info);
@ -348,7 +348,7 @@ class mysqli_native_moodle_database extends moodle_database {
/**
* Returns supported query parameter types
* @return int bitmask
* @return int bitmask of accepted SQL_PARAMS_*
*/
protected function allowed_param_types() {
return SQL_PARAMS_QM;
@ -364,6 +364,7 @@ class mysqli_native_moodle_database extends moodle_database {
/**
* Return tables in database WITHOUT current prefix
* @param bool $usecache if true, returns list of cached tables.
* @return array of table names in lowercase and without prefix
*/
public function get_tables($usecache=true) {
@ -395,8 +396,9 @@ class mysqli_native_moodle_database extends moodle_database {
}
/**
* Return table indexes - everything lowercased
* @return array of arrays
* Return table indexes - everything lowercased.
* @param string $table The table we want to get indexes from.
* @return array An associative array of indexes containing 'unique' flag and 'columns' being indexed
*/
public function get_indexes($table) {
$indexes = array();
@ -659,7 +661,7 @@ class mysqli_native_moodle_database extends moodle_database {
* Do NOT use in code, to be used by database_manager only!
* @param string $sql query
* @return bool true
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function change_database_structure($sql) {
$this->reset_caches();
@ -706,7 +708,7 @@ class mysqli_native_moodle_database extends moodle_database {
* @param string $sql query
* @param array $params query parameters
* @return bool true
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function execute($sql, array $params=null) {
list($sql, $params, $type) = $this->fix_sql_params($sql, $params);
@ -744,7 +746,7 @@ class mysqli_native_moodle_database extends moodle_database {
* @param int $limitfrom return a subset of records, starting at this point (optional, required if $limitnum is set).
* @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set).
* @return moodle_recordset instance
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function get_recordset_sql($sql, array $params=null, $limitfrom=0, $limitnum=0) {
$limitfrom = (int)$limitfrom;
@ -786,7 +788,7 @@ class mysqli_native_moodle_database extends moodle_database {
* @param int $limitfrom return a subset of records, starting at this point (optional, required if $limitnum is set).
* @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set).
* @return array of objects, or empty array if no records were found
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function get_records_sql($sql, array $params=null, $limitfrom=0, $limitnum=0) {
$limitfrom = (int)$limitfrom;
@ -830,7 +832,7 @@ class mysqli_native_moodle_database extends moodle_database {
* @param string $sql The SQL query
* @param array $params array of sql parameters
* @return array of values
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function get_fieldset_sql($sql, array $params=null) {
list($sql, $params, $type) = $this->fix_sql_params($sql, $params);
@ -858,7 +860,7 @@ class mysqli_native_moodle_database extends moodle_database {
* @param bool $bulk true means repeated inserts expected
* @param bool $customsequence true if 'id' included in $params, disables $returnid
* @return bool|int true or new id
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function insert_record_raw($table, $params, $returnid=true, $bulk=false, $customsequence=false) {
if (!is_array($params)) {
@ -913,7 +915,7 @@ class mysqli_native_moodle_database extends moodle_database {
* @param object $data A data object with values for one or more fields in the record
* @param bool $returnid Should the id of the newly created record entry be returned? If this option is not requested then true/false is returned.
* @return bool|int true or new id
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function insert_record($table, $dataobject, $returnid=true, $bulk=false) {
$dataobject = (array)$dataobject;
@ -942,7 +944,7 @@ class mysqli_native_moodle_database extends moodle_database {
* @param string $table name of database table to be inserted into
* @param object $dataobject A data object with values for one or more fields in the record
* @return bool true
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function import_record($table, $dataobject) {
$dataobject = (array)$dataobject;
@ -966,7 +968,7 @@ class mysqli_native_moodle_database extends moodle_database {
* @param mixed $params data record as object or array
* @param bool true means repeated updates expected
* @return bool true
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function update_record_raw($table, $params, $bulk=false) {
$params = (array)$params;
@ -1012,7 +1014,7 @@ class mysqli_native_moodle_database extends moodle_database {
* @param object $dataobject An object with contents equal to fieldname=>fieldvalue. Must have an entry for 'id' to map to the table specified.
* @param bool true means repeated updates expected
* @return bool true
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function update_record($table, $dataobject, $bulk=false) {
$dataobject = (array)$dataobject;
@ -1040,7 +1042,7 @@ class mysqli_native_moodle_database extends moodle_database {
* @param string $select A fragment of SQL to be used in a where clause in the SQL call.
* @param array $params array of sql parameters
* @return bool true
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function set_field_select($table, $newfield, $newvalue, $select, array $params=null) {
if ($select) {
@ -1080,7 +1082,7 @@ class mysqli_native_moodle_database extends moodle_database {
* @param string $select A fragment of SQL to be used in a where clause in the SQL call (used to define the selection criteria).
* @param array $params array of sql parameters
* @return bool true
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function delete_records_select($table, $select, array $params=null) {
if ($select) {

View File

@ -132,10 +132,10 @@ class oci_native_moodle_database extends moodle_database {
/**
* Connect to db
* Must be called before other methods.
* @param string $dbhost
* @param string $dbuser
* @param string $dbpass
* @param string $dbname
* @param string $dbhost The database host.
* @param string $dbuser The database username.
* @param string $dbpass The database username's password.
* @param string $dbname The name of the database being connected to.
* @param mixed $prefix string means moodle db prefix, false used for external databases where prefix not used
* @param array $dboptions driver specific options
* @return bool true
@ -270,7 +270,7 @@ class oci_native_moodle_database extends moodle_database {
/**
* Returns database server info array
* @return array
* @return array Array containing 'description' and 'version' info
*/
public function get_server_info() {
static $info = null; // TODO: move to real object property
@ -315,7 +315,7 @@ class oci_native_moodle_database extends moodle_database {
/**
* Returns supported query parameter types
* @return int bitmask
* @return int bitmask of accepted SQL_PARAMS_*
*/
protected function allowed_param_types() {
return SQL_PARAMS_NAMED;
@ -386,6 +386,7 @@ class oci_native_moodle_database extends moodle_database {
/**
* Return tables in database WITHOUT current prefix
* @param bool $usecache if true, returns list of cached tables.
* @return array of table names in lowercase and without prefix
*/
public function get_tables($usecache=true) {
@ -422,8 +423,9 @@ class oci_native_moodle_database extends moodle_database {
}
/**
* Return table indexes - everything lowercased
* @return array of arrays
* Return table indexes - everything lowercased.
* @param string $table The table we want to get indexes from.
* @return array An associative array of indexes containing 'unique' flag and 'columns' being indexed
*/
public function get_indexes($table) {
$indexes = array();
@ -870,7 +872,7 @@ class oci_native_moodle_database extends moodle_database {
* Do NOT use in code, to be used by database_manager only!
* @param string $sql query
* @return bool true
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function change_database_structure($sql) {
$this->reset_caches();
@ -982,7 +984,7 @@ class oci_native_moodle_database extends moodle_database {
* @param string $sql query
* @param array $params query parameters
* @return bool true
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function execute($sql, array $params=null) {
list($sql, $params, $type) = $this->fix_sql_params($sql, $params);
@ -1014,7 +1016,7 @@ class oci_native_moodle_database extends moodle_database {
* IGNORE_MULTIPLE means return first, ignore multiple records found(not recommended);
* MUST_EXIST means throw exception if no record or multiple records found
* @return mixed a fieldset object containing the first matching record, false or exception if error not found depending on mode
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function get_record_sql($sql, array $params=null, $strictness=IGNORE_MISSING) {
$strictness = (int)$strictness;
@ -1046,7 +1048,7 @@ class oci_native_moodle_database extends moodle_database {
* @param int $limitfrom return a subset of records, starting at this point (optional, required if $limitnum is set).
* @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set).
* @return moodle_recordset instance
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function get_recordset_sql($sql, array $params=null, $limitfrom=0, $limitnum=0) {
@ -1080,7 +1082,7 @@ class oci_native_moodle_database extends moodle_database {
* @param int $limitfrom return a subset of records, starting at this point (optional, required if $limitnum is set).
* @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set).
* @return array of objects, or empty array if no records were found
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function get_records_sql($sql, array $params=null, $limitfrom=0, $limitnum=0) {
@ -1122,7 +1124,7 @@ class oci_native_moodle_database extends moodle_database {
* @param string $sql The SQL query
* @param array $params array of sql parameters
* @return array of values
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function get_fieldset_sql($sql, array $params=null) {
list($sql, $params, $type) = $this->fix_sql_params($sql, $params);
@ -1152,7 +1154,7 @@ class oci_native_moodle_database extends moodle_database {
* @param bool $bulk true means repeated inserts expected
* @param bool $customsequence true if 'id' included in $params, disables $returnid
* @return bool|int true or new id
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function insert_record_raw($table, $params, $returnid=true, $bulk=false, $customsequence=false) {
if (!is_array($params)) {
@ -1224,7 +1226,7 @@ class oci_native_moodle_database extends moodle_database {
* @param object $data A data object with values for one or more fields in the record
* @param bool $returnid Should the id of the newly created record entry be returned? If this option is not requested then true/false is returned.
* @return bool|int true or new id
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function insert_record($table, $dataobject, $returnid=true, $bulk=false) {
$dataobject = (array)$dataobject;
@ -1253,7 +1255,7 @@ class oci_native_moodle_database extends moodle_database {
* @param string $table name of database table to be inserted into
* @param object $dataobject A data object with values for one or more fields in the record
* @return bool true
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function import_record($table, $dataobject) {
$dataobject = (array)$dataobject;
@ -1278,7 +1280,7 @@ class oci_native_moodle_database extends moodle_database {
* @param mixed $params data record as object or array
* @param bool true means repeated updates expected
* @return bool true
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function update_record_raw($table, $params, $bulk=false) {
$params = (array)$params;
@ -1327,7 +1329,7 @@ class oci_native_moodle_database extends moodle_database {
* @param object $dataobject An object with contents equal to fieldname=>fieldvalue. Must have an entry for 'id' to map to the table specified.
* @param bool true means repeated updates expected
* @return bool true
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function update_record($table, $dataobject, $bulk=false) {
$dataobject = (array)$dataobject;
@ -1357,7 +1359,7 @@ class oci_native_moodle_database extends moodle_database {
* @param string $select A fragment of SQL to be used in a where clause in the SQL call.
* @param array $params array of sql parameters
* @return bool true
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function set_field_select($table, $newfield, $newvalue, $select, array $params=null) {
@ -1413,7 +1415,7 @@ class oci_native_moodle_database extends moodle_database {
* @param string $select A fragment of SQL to be used in a where clause in the SQL call (used to define the selection criteria).
* @param array $params array of sql parameters
* @return bool true
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function delete_records_select($table, $select, array $params=null) {
@ -1581,6 +1583,12 @@ class oci_native_moodle_database extends moodle_database {
}
}
/**
* 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)
* @return string A string with single whitespace.
*/
public function sql_empty() {
return ' ';
}

View File

@ -50,10 +50,10 @@ abstract class pdo_moodle_database extends moodle_database {
/**
* Connect to db
* Must be called before other methods.
* @param string $dbhost
* @param string $dbuser
* @param string $dbpass
* @param string $dbname
* @param string $dbhost The database host.
* @param string $dbuser The database username.
* @param string $dbpass The database username's password.
* @param string $dbname The name of the database being connected to.
* @param mixed $prefix string means moodle db prefix, false used for external databases where prefix not used
* @param array $dboptions driver specific options
* @return bool success
@ -138,7 +138,7 @@ abstract class pdo_moodle_database extends moodle_database {
/**
* Returns database server info array
* @return array
* @return array Array containing 'description' and 'version' info
*/
public function get_server_info() {
$result = array();
@ -153,7 +153,7 @@ abstract class pdo_moodle_database extends moodle_database {
/**
* Returns supported query parameter types
* @return int bitmask
* @return int bitmask of accepted SQL_PARAMS_*
*/
protected function allowed_param_types() {
return SQL_PARAMS_QM | SQL_PARAMS_NAMED;

View File

@ -110,10 +110,10 @@ class pgsql_native_moodle_database extends moodle_database {
/**
* Connect to db
* Must be called before other methods.
* @param string $dbhost
* @param string $dbuser
* @param string $dbpass
* @param string $dbname
* @param string $dbhost The database host.
* @param string $dbuser The database username.
* @param string $dbpass The database username's password.
* @param string $dbname The name of the database being connected to.
* @param mixed $prefix string means moodle db prefix, false used for external databases where prefix not used
* @param array $dboptions driver specific options
* @return bool true
@ -234,7 +234,7 @@ class pgsql_native_moodle_database extends moodle_database {
/**
* Returns database server info array
* @return array
* @return array Array containing 'description' and 'version' info
*/
public function get_server_info() {
static $info;
@ -254,7 +254,7 @@ class pgsql_native_moodle_database extends moodle_database {
/**
* Returns supported query parameter types
* @return int bitmask
* @return int bitmask of accepted SQL_PARAMS_*
*/
protected function allowed_param_types() {
return SQL_PARAMS_DOLLAR;
@ -269,7 +269,8 @@ class pgsql_native_moodle_database extends moodle_database {
}
/**
* Return tables in database WITHOUT current prefix
* Return tables in database WITHOUT current prefix.
* @param bool $usecache if true, returns list of cached tables.
* @return array of table names in lowercase and without prefix
*/
public function get_tables($usecache=true) {
@ -303,7 +304,8 @@ class pgsql_native_moodle_database extends moodle_database {
}
/**
* Return table indexes - everything lowercased
* Return table indexes - everything lowercased.
* @param string $table The table we want to get indexes from.
* @return array of arrays
*/
public function get_indexes($table) {
@ -563,7 +565,7 @@ class pgsql_native_moodle_database extends moodle_database {
* Do NOT use in code, to be used by database_manager only!
* @param string $sql query
* @return bool true
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function change_database_structure($sql) {
$this->reset_caches();
@ -582,7 +584,7 @@ class pgsql_native_moodle_database extends moodle_database {
* @param string $sql query
* @param array $params query parameters
* @return bool true
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function execute($sql, array $params=null) {
list($sql, $params, $type) = $this->fix_sql_params($sql, $params);
@ -613,7 +615,7 @@ class pgsql_native_moodle_database extends moodle_database {
* @param int $limitfrom return a subset of records, starting at this point (optional, required if $limitnum is set).
* @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set).
* @return moodle_recordset instance
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function get_recordset_sql($sql, array $params=null, $limitfrom=0, $limitnum=0) {
$limitfrom = (int)$limitfrom;
@ -655,7 +657,7 @@ class pgsql_native_moodle_database extends moodle_database {
* @param int $limitfrom return a subset of records, starting at this point (optional, required if $limitnum is set).
* @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set).
* @return array of objects, or empty array if no records were found
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function get_records_sql($sql, array $params=null, $limitfrom=0, $limitnum=0) {
$limitfrom = (int)$limitfrom;
@ -717,7 +719,7 @@ class pgsql_native_moodle_database extends moodle_database {
* @param string $sql The SQL query
* @param array $params array of sql parameters
* @return array of values
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function get_fieldset_sql($sql, array $params=null) {
list($sql, $params, $type) = $this->fix_sql_params($sql, $params);
@ -740,7 +742,7 @@ class pgsql_native_moodle_database extends moodle_database {
* @param bool $bulk true means repeated inserts expected
* @param bool $customsequence true if 'id' included in $params, disables $returnid
* @return bool|int true or new id
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function insert_record_raw($table, $params, $returnid=true, $bulk=false, $customsequence=false) {
if (!is_array($params)) {
@ -803,7 +805,7 @@ class pgsql_native_moodle_database extends moodle_database {
* @param object $data A data object with values for one or more fields in the record
* @param bool $returnid Should the id of the newly created record entry be returned? If this option is not requested then true/false is returned.
* @return bool|int true or new id
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function insert_record($table, $dataobject, $returnid=true, $bulk=false) {
$dataobject = (array)$dataobject;
@ -857,7 +859,7 @@ class pgsql_native_moodle_database extends moodle_database {
* @param string $table name of database table to be inserted into
* @param object $dataobject A data object with values for one or more fields in the record
* @return bool true
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function import_record($table, $dataobject) {
$dataobject = (array)$dataobject;
@ -904,7 +906,7 @@ class pgsql_native_moodle_database extends moodle_database {
* @param mixed $params data record as object or array
* @param bool true means repeated updates expected
* @return bool true
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function update_record_raw($table, $params, $bulk=false) {
$params = (array)$params;
@ -950,7 +952,7 @@ class pgsql_native_moodle_database extends moodle_database {
* @param object $dataobject An object with contents equal to fieldname=>fieldvalue. Must have an entry for 'id' to map to the table specified.
* @param bool true means repeated updates expected
* @return bool true
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function update_record($table, $dataobject, $bulk=false) {
$dataobject = (array)$dataobject;
@ -1003,7 +1005,7 @@ class pgsql_native_moodle_database extends moodle_database {
* @param string $select A fragment of SQL to be used in a where clause in the SQL call.
* @param array $params array of sql parameters
* @return bool true
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function set_field_select($table, $newfield, $newvalue, $select, array $params=null) {
@ -1056,7 +1058,7 @@ class pgsql_native_moodle_database extends moodle_database {
* @param string $select A fragment of SQL to be used in a where clause in the SQL call (used to define the selection criteria).
* @param array $params array of sql parameters
* @return bool true
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function delete_records_select($table, $select, array $params=null) {
if ($select) {

View File

@ -132,7 +132,8 @@ class sqlite3_pdo_moodle_database extends pdo_moodle_database {
}
/**
* Return tables in database WITHOUT current prefix
* Return tables in database WITHOUT current prefix.
* @param bool $usecache if true, returns list of cached tables.
* @return array of table names in lowercase and without prefix
*/
public function get_tables($usecache=true) {
@ -156,6 +157,7 @@ class sqlite3_pdo_moodle_database extends pdo_moodle_database {
/**
* Return table indexes - everything lowercased
* @param string $table The table we want to get indexes from.
* @return array of arrays
*/
public function get_indexes($table) {

View File

@ -126,12 +126,12 @@ class sqlsrv_native_moodle_database extends moodle_database {
/**
* Connect to db
* Must be called before other methods.
* @param string $dbhost
* @param string $dbuser
* @param string $dbpass
* @param string $dbname
* @param mixed $prefix string means moodle db prefix, false used for external databases where prefix not used
* Must be called before most other methods. (you can call methods that return connection configuration parameters)
* @param string $dbhost The database host.
* @param string $dbuser The database username.
* @param string $dbpass The database username's password.
* @param string $dbname The name of the database being connected to.
* @param mixed $prefix string|bool The moodle db table name's prefix. false is used for external databases where prefix not used
* @param array $dboptions driver specific options
* @return bool true
* @throws dml_connection_exception if error
@ -234,7 +234,7 @@ class sqlsrv_native_moodle_database extends moodle_database {
/**
* Called before each db query.
* @param string $sql
* @param array array of parameters
* @param array $params array of parameters
* @param int $type type of query
* @param mixed $extrainfo driver specific extra information
* @return void
@ -254,7 +254,7 @@ class sqlsrv_native_moodle_database extends moodle_database {
/**
* Returns database server info array
* @return array
* @return array Array containing 'description', 'version' and 'database' (current db) info
*/
public function get_server_info() {
static $info;
@ -375,7 +375,8 @@ class sqlsrv_native_moodle_database extends moodle_database {
}
/**
* Return tables in database WITHOUT current prefix
* Return tables in database WITHOUT current prefix.
* @param bool $usecache if true, returns list of cached tables.
* @return array of table names in lowercase and without prefix
*/
public function get_tables($usecache = true) {
@ -410,7 +411,8 @@ class sqlsrv_native_moodle_database extends moodle_database {
}
/**
* Return table indexes - everything lowercased
* Return table indexes - everything lowercased.
* @param string $table The table we want to get indexes from.
* @return array of arrays
*/
public function get_indexes($table) {
@ -665,7 +667,7 @@ class sqlsrv_native_moodle_database extends moodle_database {
* Do NOT use in code, to be used by database_manager only!
* @param string $sql query
* @return bool true
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function change_database_structure($sql) {
$this->reset_caches();
@ -728,7 +730,7 @@ class sqlsrv_native_moodle_database extends moodle_database {
* @param string $sql query
* @param array $params query parameters
* @return bool true
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function execute($sql, array $params = null) {
if (strpos($sql, ';') !== false) {
@ -752,7 +754,7 @@ class sqlsrv_native_moodle_database extends moodle_database {
* @param int $limitfrom return a subset of records, starting at this point (optional, required if $limitnum is set).
* @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set).
* @return moodle_recordset instance
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function get_recordset_sql($sql, array $params = null, $limitfrom = 0, $limitnum = 0) {
$limitfrom = (int)$limitfrom;
@ -800,7 +802,7 @@ class sqlsrv_native_moodle_database extends moodle_database {
* @param int $limitfrom return a subset of records, starting at this point (optional, required if $limitnum is set).
* @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set).
* @return array of objects, or empty array if no records were found
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function get_records_sql($sql, array $params = null, $limitfrom = 0, $limitnum = 0) {
@ -828,7 +830,7 @@ class sqlsrv_native_moodle_database extends moodle_database {
* @param string $sql The SQL query
* @param array $params array of sql parameters
* @return array of values
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function get_fieldset_sql($sql, array $params = null) {
@ -852,7 +854,7 @@ class sqlsrv_native_moodle_database extends moodle_database {
* @param bool $bulk true means repeated inserts expected
* @param bool $customsequence true if 'id' included in $params, disables $returnid
* @return bool|int true or new id
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function insert_record_raw($table, $params, $returnid=true, $bulk=false, $customsequence=false) {
if (!is_array($params)) {
@ -937,7 +939,7 @@ class sqlsrv_native_moodle_database extends moodle_database {
* @param object $data A data object with values for one or more fields in the record
* @param bool $returnid Should the id of the newly created record entry be returned? If this option is not requested then true/false is returned.
* @return bool|int true or new id
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function insert_record($table, $dataobject, $returnid = true, $bulk = false) {
$dataobject = (array)$dataobject;
@ -966,7 +968,7 @@ class sqlsrv_native_moodle_database extends moodle_database {
* @param string $table name of database table to be inserted into
* @param object $dataobject A data object with values for one or more fields in the record
* @return bool true
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function import_record($table, $dataobject) {
if (!is_object($dataobject)) {
@ -995,7 +997,7 @@ class sqlsrv_native_moodle_database extends moodle_database {
* @param mixed $params data record as object or array
* @param bool true means repeated updates expected
* @return bool true
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function update_record_raw($table, $params, $bulk = false) {
$params = (array)$params;
@ -1037,7 +1039,7 @@ class sqlsrv_native_moodle_database extends moodle_database {
* @param object $dataobject An object with contents equal to fieldname=>fieldvalue. Must have an entry for 'id' to map to the table specified.
* @param bool true means repeated updates expected
* @return bool true
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function update_record($table, $dataobject, $bulk = false) {
$dataobject = (array)$dataobject;
@ -1065,7 +1067,7 @@ class sqlsrv_native_moodle_database extends moodle_database {
* @param string $select A fragment of SQL to be used in a where clause in the SQL call.
* @param array $params array of sql parameters
* @return bool true
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function set_field_select($table, $newfield, $newvalue, $select, array $params = null) {
if ($select) {
@ -1105,7 +1107,7 @@ class sqlsrv_native_moodle_database extends moodle_database {
* @param string $select A fragment of SQL to be used in a where clause in the SQL call (used to define the selection criteria).
* @param array $params array of sql parameters
* @return bool true
* @throws dml_exception if error
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function delete_records_select($table, $select, array $params = null) {
if ($select) {