SelectQuery
abstract class SelectQuery
Query builder for civicrm_api_basic_get.
Fetches an entity based on specified params for the "where" clause, return properties for the "select" clause, as well as limit and order.
Automatically joins on custom fields to return or filter by them.
Supports an additional sql fragment which the calling api can provide.
Constants
MAX_JOINS |
|
MAIN_TABLE_ALIAS |
|
Properties
protected string | $entity | ||
$select | |||
$where | |||
$orderBy | |||
$limit | |||
$offset | |||
protected array | $selectFields | ||
bool | $isFillUniqueFields | ||
protected CRM_Utils_SQL_Select | $query | ||
protected array | $joins | ||
protected array | $apiFieldSpec | ||
protected array | $entityFieldNames | ||
protected array | $aclFields | ||
protected string|bool | $checkPermissions | ||
protected | $apiVersion |
Methods
No description
Build & execute the query and return results array
Joins onto an fk field
Get join info for dynamically-joined fields (e.g. "entity_id", "option_group")
Joins onto a custom field
Fetch a field from the getFields list
Perform input validation on params that use the join syntax
Check permission to join onto another api entity
Get acl clause for an entity
Orders the query by one or more fields
No description
Populate where clauses
Populate $this->selectFields
Load entity fields
Details
at line 98
__construct(string $entity, bool $checkPermissions)
at line 122
array|int
run()
Build & execute the query and return results array
at line 174
SelectQuery
merge(CRM_Utils_SQL_Select $sqlFragment)
at line 194
protected array|null
addFkField($fkFieldName, $side)
Joins onto an fk field
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.
at line 275
protected
getJoinInfo($fkField, $stack)
Get join info for dynamically-joined fields (e.g. "entity_id", "option_group")
at line 303
protected array
addCustomField(array $customField, string $side, string $baseTable = self::MAIN_TABLE_ALIAS)
Joins onto a custom field
Adds a join to the query to make this field available for use in a clause.
at line 317
abstract protected array|null
getField(string $fieldName)
Fetch a field from the getFields list
at line 329
protected
validateNestedInput($fieldName, $value)
Perform input validation on params that use the join syntax
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.
at line 350
protected bool
checkPermissionToJoin(string $entity, array $fieldStack)
Check permission to join onto another api entity
at line 384
protected array
getAclClause(string $tableAlias, string $baoName, array $stack = [])
Get acl clause for an entity
at line 408
protected
buildOrderBy()
Orders the query by one or more fields
at line 442
join(string $side, string $tableName, string $tableAlias, array $conditions)
at line 456
abstract protected
buildWhereClause()
Populate where clauses
at line 463
protected
buildSelectFields()
Populate $this->selectFields
at line 514
abstract protected array
getFields()
Load entity fields