CRM_Utils_SQL
in package
Just another collection of static utils functions.
Tags
Table of Contents
Methods
- autoSwitchDSN() : string
- If DB_DSN_MODE is auto then we should replace mysql with mysqli if mysqli is available or the other way around as appropriate
- disableFullGroupByMode() : bool
- Disable ONLY_FULL_GROUP_BY for MySQL versions lower then 5.7
- getDatabaseVersion() : string
- Get the version string for the database.
- getSqlModes() : array<string|int, mixed>
- Get current sqlModes of the session
- handleEmojiInQuery() : bool|string
- Filter out Emojis in where clause if the database (determined by checking the create table for civicrm_contact) cannot support emojis
- interpolate() : string
- Given a string like "UPDATE some_table SET !field = @value", replace "!field" and "@value".
- isGroupByModeInDefault() : bool
- CHeck if ONLY_FULL_GROUP_BY is in the global sql_modes
- isSSLDSN() : bool
- Does the DSN indicate the connection should use ssl.
- mergeSubquery() : array<string|int, mixed>
- Helper function for adding the permissioned subquery from one entity onto another
- prefixFieldNames() : string|array<string|int, mixed>
- Walk a nested array and replace "{field_name}" with "`tableAlias`.`field_name`"
- supportsFullGroupBy() : mixed
- Checks if this system enforce the MYSQL mode ONLY_FULL_GROUP_BY.
Methods
autoSwitchDSN()
If DB_DSN_MODE is auto then we should replace mysql with mysqli if mysqli is available or the other way around as appropriate
public
static autoSwitchDSN(string $dsn) : string
Parameters
- $dsn : string
Return values
stringdisableFullGroupByMode()
Disable ONLY_FULL_GROUP_BY for MySQL versions lower then 5.7
public
static disableFullGroupByMode() : bool
Return values
boolgetDatabaseVersion()
Get the version string for the database.
public
static getDatabaseVersion() : string
Return values
stringgetSqlModes()
Get current sqlModes of the session
public
static getSqlModes() : array<string|int, mixed>
Return values
array<string|int, mixed>handleEmojiInQuery()
Filter out Emojis in where clause if the database (determined by checking the create table for civicrm_contact) cannot support emojis
public
static handleEmojiInQuery(mixed $criteria) : bool|string
Parameters
- $criteria : mixed
-
- filter criteria to check
Return values
bool|stringinterpolate()
Given a string like "UPDATE some_table SET !field = @value", replace "!field" and "@value".
public
static interpolate(string $expr, null|array<string|int, mixed> $args) : string
This is syntactic sugar for using CRM_Utils_SQL_*::interpolate() without an OOP representation of the query.
Parameters
- $expr : string
-
SQL expression
- $args : null|array<string|int, mixed>
-
a list of values to insert into the SQL expression; keys are prefix-coded: prefix '@' => escape SQL prefix '#' => literal number, skip escaping but do validation prefix '!' => literal, skip escaping and validation if a value is an array, then it will be imploded
PHP NULL's will be treated as SQL NULL's. The PHP string "null" will be treated as a string.
Return values
stringisGroupByModeInDefault()
CHeck if ONLY_FULL_GROUP_BY is in the global sql_modes
public
static isGroupByModeInDefault() : bool
Return values
boolisSSLDSN()
Does the DSN indicate the connection should use ssl.
public
static isSSLDSN(string $dsn) : bool
Parameters
- $dsn : string
Return values
boolmergeSubquery()
Helper function for adding the permissioned subquery from one entity onto another
public
static mergeSubquery(string $entityName[, string $joinColumn = 'id' ]) : array<string|int, mixed>
Parameters
- $entityName : string
- $joinColumn : string = 'id'
Return values
array<string|int, mixed>prefixFieldNames()
Walk a nested array and replace "{field_name}" with "`tableAlias`.`field_name`"
public
static prefixFieldNames(string|array<string|int, mixed> &$clause, array<string|int, mixed> $fieldNames, string $tableAlias) : string|array<string|int, mixed>
Parameters
- $clause : string|array<string|int, mixed>
- $fieldNames : array<string|int, mixed>
- $tableAlias : string
Return values
string|array<string|int, mixed>supportsFullGroupBy()
Checks if this system enforce the MYSQL mode ONLY_FULL_GROUP_BY.
public
static supportsFullGroupBy() : mixed
This function should be named supportsAnyValueAndEnforcesFullGroupBY(), but should be deprecated instead.