Documentation

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][]

$entityValues

protected array<string|int, mixed> $entityValues = []

Methods

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
throws
CRM_Core_Exception
throws
Exception
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|string

getGroupBy()

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>

getOrderBy()

public getOrderBy() : array<string|int, mixed>
Return values
array<string|int, mixed>

getResults()

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
throws
CRM_Core_Exception
Return values
string

getWhere()

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
throws
CRM_Core_Exception
uses
composeClause()

to generate the SQL etc.

Return values
string

SQL where clause

buildGroupBy()

Add GROUP BY clause to query

protected buildGroupBy() : mixed

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
throws
Exception
Return values
array<string|int, mixed>|string|null

isAggregateQuery()

protected isAggregateQuery() : mixed

        
On this page

Search results