Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400] [Versions 400 and 402] [Versions 400 and 403]

Abstract database driver test class providing some moodle database interface

Copyright: 2018 Srdjan Janković, Catalyst IT
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 399 lines (11 kb)
Included or required: 1 time
Referenced: 0 times
Includes or requires: 4 files
 lib/dml/moodle_database.php
 lib/dml/tests/fixtures/test_sql_generator.php
 lib/ddl/database_manager.php
 lib/dml/moodle_temptables.php

Defines 1 class


Class: test_moodle_database  - X-Ref

Abstract database driver test class

__construct($external = false)   X-Ref
Constructor - Instantiates the database

param: bool $external True means that an external database is used.

driver_installed()   X-Ref
Default implementation

return: boolean true

get_dbfamily()   X-Ref
Default implementation

return: string 'test'

get_dbtype()   X-Ref
Default implementation

return: string 'test'

get_dblibrary()   X-Ref
Default implementation

return: string 'test'

get_name()   X-Ref
Default implementation

return: string 'test'

get_configuration_help()   X-Ref
Default implementation

return: string

get_server_info()   X-Ref
Default implementation

return: array

allowed_param_types()   X-Ref
Default implementation

return: int 0

get_last_error()   X-Ref
Returns error property

return: string $error

set_tables($tables)   X-Ref
Sets tables property

return: void
param: array $tables

get_tables($usecache = true)   X-Ref
Returns keys of tables property

return: array $tablenames
param: bool $usecache

get_indexes($table)   X-Ref
Return table indexes

return: array $indexes
param: string $table

fetch_columns($table)   X-Ref
Return table columns

return: array database_column_info[] of database_column_info objects indexed with column names
param: string $table

normalise_value($column, $value)   X-Ref
Default implementation

return: mixed $value
param: StdClass $column metadata
param: mixed $value

change_database_structure($sql, $tablenames = null)   X-Ref
Default implementation

return: bool true
param: string|array $sql
param: array|null $tablenames

execute($sql, array $params = null)   X-Ref
Default implementation, throws Exception

return: bool true
param: string $sql
param: array $params

get_recordset_sql($sql, array $params = null, $limitfrom = 0, $limitnum = 0)   X-Ref
Default implementation, throws Exception

return: bool true
param: string $sql
param: array $params
param: int $limitfrom
param: int $limitnum

get_records_sql($sql, array $params = null, $limitfrom = 0, $limitnum = 0)   X-Ref
Default implementation, throws Exception

return: bool true
param: string $sql
param: array $params
param: int $limitfrom
param: int $limitnum

get_fieldset_sql($sql, array $params = null)   X-Ref
Default implementation, throws Exception

return: bool true
param: string $sql
param: array $params

insert_record_raw($table, $params, $returnid = true, $bulk = false, $customsequence = false)   X-Ref
Default implementation, throws Exception

return: bool|int true or new id
param: string $table
param: array $params
param: bool $returnid
param: bool $bulk
param: bool $customsequence

insert_record($table, $dataobject, $returnid = true, $bulk = false)   X-Ref
Default implementation, throws Exception

return: bool|int true or new id
param: string $table
param: object|array $dataobject
param: bool $returnid
param: bool $bulk

import_record($table, $dataobject)   X-Ref
Default implementation, throws Exception

return: bool true
param: string $table
param: StdObject $dataobject

update_record_raw($table, $params, $bulk = false)   X-Ref
Default implementation, throws Exception

return: bool true
param: string $table
param: array $params
param: bool $bulk

update_record($table, $dataobject, $bulk = false)   X-Ref
Default implementation, throws Exception

return: bool true
param: string $table
param: StdObject $dataobject
param: bool $bulk

set_field_select($table, $newfield, $newvalue, $select, array $params = null)   X-Ref
Default implementation, throws Exception

return: bool true
param: string $table
param: string $newfield
param: string $newvalue
param: string $select
param: array $params

delete_records_select($table, $select, array $params = null)   X-Ref
Default implementation, throws Exception

return: bool true
param: string $table
param: string $select
param: array $params

sql_concat()   X-Ref
Default implementation, throws Exception

return: string $sql

sql_concat_join($separator = "' '", $elements = [])   X-Ref
Default implementation, throws Exception

return: string $sql
param: string $separator
param: array  $elements

sql_group_concat(string $field, string $separator = ', ', string $sort = '')   X-Ref
Default implementation, throws Exception

return: string
param: string $field
param: string $separator
param: string $sort

begin_transaction()   X-Ref
Default implementation, throws Exception

return: void

commit_transaction()   X-Ref
Default implementation, throws Exception

return: void

rollback_transaction()   X-Ref
Default implementation, throws Exception

return: void

get_manager()   X-Ref
Returns the database manager used for db manipulation.
Used mostly in upgrade.php scripts.

return: database_manager The instance used to perform ddl operations.