Documentation

Api3SelectQuery extends SelectQuery
in package

Query builder for civicrm_api_basic_get.

Table of Contents

Constants

MAIN_TABLE_ALIAS  = 'a'
MAX_JOINS  = 4

Properties

$isFillUniqueFields  : bool
$limit  : mixed
$offset  : mixed
$orderBy  : mixed
$select  : mixed
$where  : mixed
$aclFields  : array<string|int, mixed>
$apiFieldSpec  : array<string|int, mixed>
$apiVersion  : mixed
$checkPermissions  : string|bool
$entity  : string
$entityFieldNames  : array<string|int, mixed>
$joins  : array<string|int, mixed>
$query  : CRM_Utils_SQL_Select
$selectFields  : array<string|int, mixed>

Methods

__construct()  : mixed
getAclClause()  : array<string|int, mixed>
Get acl clause for an entity
join()  : mixed
merge()  : SelectQuery
run()  : array<string|int, mixed>|int
Build & execute the query and return results array
addCustomField()  : array<string|int, mixed>
Joins onto a custom field
addFkField()  : array<string|int, mixed>|null
Joins onto an fk field
buildOrderBy()  : mixed
Orders the query by one or more fields
buildSelectFields()  : mixed
Populate $this->selectFields
buildWhereClause()  : mixed
Populate where clauses
checkPermissionToJoin()  : bool
Check permission to join onto another api entity
getField()  : null|mixed
Fetch a field from the getFields list
getFields()  : array<string|int, mixed>
Load entity fields
getJoinInfo()  : mixed
Get join info for dynamically-joined fields (e.g. "entity_id", "option_group")
validateNestedInput()  : mixed
Perform input validation on params that use the join syntax

Constants

MAIN_TABLE_ALIAS

public mixed MAIN_TABLE_ALIAS = 'a'

Properties

$isFillUniqueFields

public bool $isFillUniqueFields = FALSE

$aclFields

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

$apiFieldSpec

protected array<string|int, mixed> $apiFieldSpec

$checkPermissions

protected string|bool $checkPermissions

$entityFieldNames

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

$joins

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

$selectFields

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

Methods

__construct()

public __construct(string $entity, bool $checkPermissions) : mixed
Parameters
$entity : string
$checkPermissions : bool
Tags
throws
CRM_Core_Exception

getAclClause()

Get acl clause for an entity

public getAclClause(string $tableAlias, CRM_Core_DAO|string $baoName[, array<string|int, mixed> $stack = [] ]) : array<string|int, mixed>
Parameters
$tableAlias : string
$baoName : CRM_Core_DAO|string
$stack : array<string|int, mixed> = []
Return values
array<string|int, mixed>

join()

public join(string $side, string $tableName, string $tableAlias, array<string|int, mixed> $conditions) : mixed
Parameters
$side : string
$tableName : string
$tableAlias : string
$conditions : array<string|int, mixed>

run()

Build & execute the query and return results array

public run() : array<string|int, mixed>|int
Tags
throws
CRM_Core_Exception
throws
Exception
Return values
array<string|int, mixed>|int

addCustomField()

Joins onto a custom field

protected addCustomField(array<string|int, mixed> $customField, string $side[, string $baseTable = self::MAIN_TABLE_ALIAS ]) : array<string|int, mixed>

Adds a join to the query to make this field available for use in a clause.

Parameters
$customField : array<string|int, mixed>
$side : string
$baseTable : string = self::MAIN_TABLE_ALIAS
Return values
array<string|int, mixed>

Returns the table and field name for adding this field to a SELECT or WHERE clause

addFkField()

Joins onto an fk field

protected addFkField(mixed $fkFieldName, mixed $side) : array<string|int, mixed>|null

Adds one or more joins to the query to make this field available for use in a clause.

Enforces permissions at the api level and by appending the acl clause for that entity to the join.

Parameters
$fkFieldName : mixed
$side : mixed
Tags
throws
CRM_Core_Exception
throws
UnauthorizedException
Return values
array<string|int, mixed>|null

Returns the table and field name for adding this field to a SELECT or WHERE clause

buildWhereClause()

Populate where clauses

protected buildWhereClause() : mixed
Tags
inheritDoc

checkPermissionToJoin()

Check permission to join onto another api entity

protected checkPermissionToJoin(string $entity, array<string|int, mixed> $fieldStack) : bool
Parameters
$entity : string
$fieldStack : array<string|int, mixed>

The stack of fields leading up to this join

Return values
bool

getField()

Fetch a field from the getFields list

protected getField(string $fieldName) : null|mixed

Searches by name, uniqueName, and api.aliases

Parameters
$fieldName : string

Field name.

Return values
null|mixed

getFields()

Load entity fields

protected getFields() : array<string|int, mixed>
Tags
inheritDoc
Return values
array<string|int, mixed>

getJoinInfo()

Get join info for dynamically-joined fields (e.g. "entity_id", "option_group")

protected getJoinInfo(mixed &$fkField, mixed $stack) : mixed
Parameters
$fkField : mixed
$stack : mixed

validateNestedInput()

Perform input validation on params that use the join syntax

protected validateNestedInput(mixed $fieldName, mixed &$value) : mixed

Arguably this should be done at the api wrapper level, but doing it here provides a bit more consistency in that api permissions to perform the join are checked first.

Parameters
$fieldName : mixed
$value : mixed
Tags
throws
Exception

        
On this page

Search results