Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401]

Database driver test class for testing moodle_read_slave_trait

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

Defines 2 classes

read_slave_moodle_database_special:: (4 methods):
  get_records_sql()
  get_records_sql_p()
  get_recordset_sql()
  count_records()

read_slave_moodle_recordset_special:: (5 methods):
  close()
  current()
  next()
  key()
  valid()


Class: read_slave_moodle_database_special  - X-Ref

Database driver mock test class that uses read_slave_moodle_recordset_special

get_records_sql($sql, array $params = null, $limitfrom = 0, $limitnum = 0)   X-Ref
Returns empty array

param: string $sql the SQL select query to execute.
param: array $params array of sql parameters
param: int $limitfrom return a subset of records, starting at this point (optional).
param: int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set).
return: string $handle handle property

get_records_sql_p($sql, array $params = null, $limitfrom = 0, $limitnum = 0)   X-Ref
Returns read_slave_moodle_database::get_records_sql()
For the tests where we need both fake result and dbhandle info.

param: string $sql the SQL select query to execute.
param: array $params array of sql parameters
param: int $limitfrom return a subset of records, starting at this point (optional).
param: int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set).
return: string $handle handle property

get_recordset_sql($sql, array $params = null, $limitfrom = 0, $limitnum = 0)   X-Ref
Returns fake recordset

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

count_records($table, array $conditions = null)   X-Ref
Count the records in a table where all the given conditions met.

param: string $table The table to query.
param: array $conditions optional array $fieldname=>requestedvalue with AND in between
return: int The count of records returned from the specified criteria.

Class: read_slave_moodle_recordset_special  - X-Ref

Database recordset mock test class

close()   X-Ref
Iterator interface

return: void

current()   X-Ref
Iterator interface

return: \stdClass

next()   X-Ref
Iterator interface

return: void

key()   X-Ref
Iterator interface

return: mixed

valid()   X-Ref
Iterator interface

return: bool