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 400 and 401] [Versions 400 and 402] [Versions 400 and 403]

(no description)

File Size: 140 lines (5 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: database  - X-Ref

Helper functions for DB manipulations

generate_alias()   X-Ref
Generates unique table/column alias that must be used in generated SQL

return: string

generate_param_name()   X-Ref
Generates unique parameter name that must be used in generated SQL

return: string

validate_params(array $params)   X-Ref
Validate that parameter names were generated using {@see generate_param_name}.

return: bool
param: array $params

sql_replace_parameter_names(string $sql, array $params, callable $callback)   X-Ref
Replace parameter names within given SQL expression, allowing caller to specify callback to handle their replacement
primarily to ensure uniqueness when the expression is to be used as part of a larger query

return: string
param: string $sql
param: array $params
param: callable $callback Method that takes a single string parameter, and returns another string

sql_group_concat_sort(string $field, string $sort = null)   X-Ref
Generate SQL expression for sorting group concatenated fields

return: string
param: string $field The original field or SQL expression
param: string|null $sort A valid SQL ORDER BY to sort the concatenated fields, if omitted then $field will be used