class Api3SelectQuery extends SelectQuery

Constants

MAX_JOINS

MAIN_TABLE_ALIAS

Properties

protected string $entity from SelectQuery
$select from SelectQuery
$where from SelectQuery
$orderBy from SelectQuery
$limit from SelectQuery
$offset from SelectQuery
protected array $selectFields from SelectQuery
bool $isFillUniqueFields from SelectQuery
protected CRM_Utils_SQL_Select $query from SelectQuery
protected array $joins from SelectQuery
protected array $apiFieldSpec from SelectQuery
protected array $entityFieldNames from SelectQuery
protected array $aclFields from SelectQuery
protected string|bool $checkPermissions from SelectQuery
protected $apiVersion

Methods

__construct(string $entity, bool $checkPermissions)

No description

array|int
run()

Build & execute the query and return results array

merge(CRM_Utils_SQL_Select $sqlFragment)

No description

array|null
addFkField($fkFieldName, $side)

Joins onto an fk field

getJoinInfo($fkField, $stack)

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

array
addCustomField(array $customField, string $side, string $baseTable = self::MAIN_TABLE_ALIAS)

Joins onto a custom field

array|null
getField(string $fieldName)

Fetch a field from the getFields list

validateNestedInput($fieldName, $value)

Perform input validation on params that use the join syntax

bool
checkPermissionToJoin(string $entity, array $fieldStack)

Check permission to join onto another api entity

array
getAclClause(string $tableAlias, string $baoName, array $stack = array())

Get acl clause for an entity

buildOrderBy()

Orders the query by one or more fields

join(string $side, string $tableName, string $tableAlias, array $conditions)

No description

buildWhereClause()

No description

buildSelectFields()

Populate $this->selectFields

array
getFields()

No description

Details

in SelectQuery at line 97
__construct(string $entity, bool $checkPermissions)

Parameters

string $entity
bool $checkPermissions

in SelectQuery at line 122
array|int run()

Build & execute the query and return results array

Return Value

array|int

Exceptions

API_Exception
CRM_Core_Exception
Exception

in SelectQuery at line 176
SelectQuery merge(CRM_Utils_SQL_Select $sqlFragment)

Parameters

CRM_Utils_SQL_Select $sqlFragment

Return Value

SelectQuery

in SelectQuery at line 196
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.

Parameters

$fkFieldName
$side

Return Value

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

Exceptions

API_Exception
UnauthorizedException

in SelectQuery at line 271
protected getJoinInfo($fkField, $stack)

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

Parameters

$fkField
$stack

in SelectQuery at line 299
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.

Parameters

array $customField
string $side
string $baseTable

Return Value

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

at line 164
protected array|null getField(string $fieldName)

Fetch a field from the getFields list

Searches by name, uniqueName, and api.aliases

Parameters

string $fieldName

Return Value

array|null

in SelectQuery at line 325
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.

Parameters

$fieldName
$value

Exceptions

Exception

in SelectQuery at line 346
protected bool checkPermissionToJoin(string $entity, array $fieldStack)

Check permission to join onto another api entity

Parameters

string $entity
array $fieldStack The stack of fields leading up to this join

Return Value

bool

in SelectQuery at line 380
protected array getAclClause(string $tableAlias, string $baoName, array $stack = array())

Get acl clause for an entity

Parameters

string $tableAlias
string $baoName
array $stack

Return Value

array

in SelectQuery at line 404
protected buildOrderBy()

Orders the query by one or more fields

in SelectQuery at line 438
join(string $side, string $tableName, string $tableAlias, array $conditions)

Parameters

string $side
string $tableName
string $tableAlias
array $conditions

at line 38
protected buildWhereClause()

in SelectQuery at line 459
protected buildSelectFields()

Populate $this->selectFields

at line 144
protected array getFields()

Return Value

array