Api4Query
in package
AbstractYes
A query `node` may be in one of three formats:
- leaf: [$fieldName, $operator, $criteria]
- negated: ['NOT', $node]
- branch: ['OR|NOT', [$node, $node, ...]]
Leaf operators are one of:
- '=', '<=', '>=', '>', '<', 'LIKE', "<>", "!=",
- 'NOT LIKE', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN',
- 'IS NOT NULL', 'IS NULL', 'CONTAINS', 'NOT CONTAINS',
- 'IS EMPTY', 'IS NOT EMPTY', 'REGEXP', 'NOT REGEXP'
- 'REGEXP BINARY', 'NOT REGEXP BINARY'
Table of Contents
Constants
- MAIN_TABLE_ALIAS = 'a'
- UNLIMITED = '18446744073709551615'
Properties
- $apiFieldSpec : array<string|int, array<string|int, mixed>>
- $selectAliases : array<string|int, mixed>
- $api : AbstractQueryAction
- $entityValues : array<string|int, mixed>
- $query : CRM_Utils_SQL_Select
Methods
- __construct() : mixed
- addSpecField() : mixed
- composeClause() : string
- Validate and transform a leaf clause array to SQL.
- debug() : mixed
- Add something to the api's debug output if debugging is enabled
- getApiParam() : mixed
- getCheckPermissions() : bool|string
- getGroupBy() : array<string|int, mixed>
- getHaving() : array<string|int, mixed>
- getJoin() : array<string|int, mixed>
- getLimit() : mixed
- getOffset() : mixed
- getOrderBy() : array<string|int, mixed>
- getQuery() : CRM_Utils_SQL_Select
- getResults() : array<string|int, mixed>
- getSelect() : array<string|int, mixed>
- getSql() : string
- Builds main final sql statement after initialization.
- getWhere() : array<string|int, mixed>
- treeWalkClauses() : string
- Recursively validate and transform a branch or leaf clause array to SQL.
- buildGroupBy() : mixed
- Add GROUP BY clause to query
- buildLimit() : mixed
- Add LIMIT to query
- createSQLClause() : array<string|int, mixed>|string|null
- getExpression() : SqlExpression
- isAggregateQuery() : mixed
Constants
MAIN_TABLE_ALIAS
public
mixed
MAIN_TABLE_ALIAS
= 'a'
UNLIMITED
public
mixed
UNLIMITED
= '18446744073709551615'
Properties
$apiFieldSpec
public
array<string|int, array<string|int, mixed>>
$apiFieldSpec
= []
$selectAliases
public
array<string|int, mixed>
$selectAliases
= []
[alias => expr][]
$api
protected
AbstractQueryAction
$api
$entityValues
protected
array<string|int, mixed>
$entityValues
= []
$query
protected
CRM_Utils_SQL_Select
$query
Methods
__construct()
public
__construct(AbstractQueryAction $api) : mixed
Parameters
- $api : AbstractQueryAction
addSpecField()
public
addSpecField(string $path, array<string|int, mixed> $field) : mixed
Parameters
- $path : string
- $field : array<string|int, mixed>
composeClause()
Validate and transform a leaf clause array to SQL.
public
composeClause(array<string|int, mixed> $clause, string $type, int $depth) : string
Parameters
- $clause : array<string|int, mixed>
-
[$fieldName, $operator, $criteria, $isExpression]
- $type : string
-
WHERE|HAVING|ON
- $depth : int
Tags
Return values
string —SQL
debug()
Add something to the api's debug output if debugging is enabled
public
debug(mixed $key, mixed $item) : mixed
Parameters
- $key : mixed
- $item : mixed
getApiParam()
public
getApiParam(mixed $param) : mixed
Parameters
- $param : mixed
getCheckPermissions()
public
getCheckPermissions() : bool|string
Return values
bool|stringgetGroupBy()
public
getGroupBy() : array<string|int, mixed>
Return values
array<string|int, mixed>getHaving()
public
getHaving() : array<string|int, mixed>
Return values
array<string|int, mixed>getJoin()
public
getJoin() : array<string|int, mixed>
Return values
array<string|int, mixed>getLimit()
public
getLimit() : mixed
getOffset()
public
getOffset() : mixed
getOrderBy()
public
getOrderBy() : array<string|int, mixed>
Return values
array<string|int, mixed>getQuery()
public
getQuery() : CRM_Utils_SQL_Select
Return values
CRM_Utils_SQL_SelectgetResults()
public
getResults() : array<string|int, mixed>
Return values
array<string|int, mixed>getSelect()
public
getSelect() : array<string|int, mixed>
Return values
array<string|int, mixed>getSql()
Builds main final sql statement after initialization.
public
getSql() : string
Tags
Return values
stringgetWhere()
public
getWhere() : array<string|int, mixed>
Return values
array<string|int, mixed>treeWalkClauses()
Recursively validate and transform a branch or leaf clause array to SQL.
public
treeWalkClauses(array<string|int, mixed> $clause, string $type[, int $depth = 0 ]) : string
Parameters
- $clause : array<string|int, mixed>
- $type : string
-
WHERE|HAVING|ON
- $depth : int = 0
Tags
Return values
string —SQL where clause
buildGroupBy()
Add GROUP BY clause to query
protected
buildGroupBy() : mixed
buildLimit()
Add LIMIT to query
protected
buildLimit() : mixed
Tags
createSQLClause()
protected
createSQLClause(string $fieldAlias, string $operator, mixed $value, array<string|int, mixed>|null $field, int $depth) : array<string|int, mixed>|string|null
Parameters
- $fieldAlias : string
- $operator : string
- $value : mixed
- $field : array<string|int, mixed>|null
- $depth : int
Tags
Return values
array<string|int, mixed>|string|nullgetExpression()
protected
getExpression(string $expr[, array<string|int, mixed> $allowedTypes = NULL ]) : SqlExpression
Parameters
- $expr : string
- $allowedTypes : array<string|int, mixed> = NULL
Tags
Return values
SqlExpressionisAggregateQuery()
protected
isAggregateQuery() : mixed