Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
core_reportbuilder\local\helpers\database Class Reference

Static Public Member Functions

static generate_alias ()
 Generates unique table/column alias that must be used in generated SQL.
 
static generate_aliases (int $count)
 Generate multiple unique table/column aliases, see {.
 
static generate_param_name ()
 Generates unique parameter name that must be used in generated SQL.
 
static generate_param_names (int $count)
 Generate multiple unique parameter names, see {.
 
static sql_group_concat_sort (string $field, string $sort=null)
 Generate SQL expression for sorting group concatenated fields.
 
static sql_replace_parameter_names (string $sql, array $params, callable $callback)
 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.
 
static sql_replace_parameters (string $sql, array $params, callable $callback)
 Replace parameter names within given SQL expression, returning updated SQL and parameter elements.
 
static validate_params (array $params)
 Validate that parameter names were generated using {.
 

Member Function Documentation

◆ generate_alias()

static core_reportbuilder\local\helpers\database::generate_alias ( )
static

Generates unique table/column alias that must be used in generated SQL.

Return values
string

◆ generate_aliases()

static core_reportbuilder\local\helpers\database::generate_aliases ( int $count)
static

Generate multiple unique table/column aliases, see {.

See also
generate_alias} for info
Parameters
int$count
Return values
string[]

◆ generate_param_name()

static core_reportbuilder\local\helpers\database::generate_param_name ( )
static

Generates unique parameter name that must be used in generated SQL.

Return values
string

◆ generate_param_names()

static core_reportbuilder\local\helpers\database::generate_param_names ( int $count)
static

Generate multiple unique parameter names, see {.

See also
generate_param_name} for info
Parameters
int$count
Return values
string[]

◆ sql_group_concat_sort()

static core_reportbuilder\local\helpers\database::sql_group_concat_sort ( string $field,
string $sort = null )
static

Generate SQL expression for sorting group concatenated fields.

Parameters
string$fieldThe original field or SQL expression
string | null$sortA valid SQL ORDER BY to sort the concatenated fields, if omitted then $field will be used
Return values
string

◆ sql_replace_parameter_names()

static core_reportbuilder\local\helpers\database::sql_replace_parameter_names ( string $sql,
array $params,
callable $callback )
static

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.

Parameters
string$sql
array$paramsParameter names
callable$callbackMethod that takes a single string parameter, and returns another string
Return values
string

◆ sql_replace_parameters()

static core_reportbuilder\local\helpers\database::sql_replace_parameters ( string $sql,
array $params,
callable $callback )
static

Replace parameter names within given SQL expression, returning updated SQL and parameter elements.

{

See also
sql_replace_parameter_names}
Parameters
string$sql
array$paramsParameter name/values
callable$callback
Return values
array[$sql, $params]

◆ validate_params()

static core_reportbuilder\local\helpers\database::validate_params ( array $params)
static

Validate that parameter names were generated using {.

See also
generate_param_name}.
Parameters
array$params
Return values
bool
Exceptions
coding_exceptionFor invalid params.

The documentation for this class was generated from the following file: