54 if (!isset($this->property_type)) {
56 $this->property_type =
'attribute';
58 $this->property_type =
'metadata';
64 $from_column =
'guid';
65 switch (
$qb->getTableName()) {
68 $from_column =
'entity_guid';
71 $from_column =
'guid_one';
72 if ((
bool) $this->inverse_relationship) {
73 $from_column =
'guid_two';
78 switch ($this->property_type) {
80 $md_alias =
$qb->joinMetadataTable($table_alias, $from_column, $this->property, $this->join_type);
86 throw new DomainException(
"'{$this->property}' is not a valid entity attribute");
90 $e_alias =
$qb->joinEntitiesTable($table_alias, $from_column, $this->join_type);
92 $e_alias = $table_alias;
95 $column =
"{$e_alias}.{$this->property}";
99 $an_alias =
$qb->joinAnnotationTable($table_alias, $from_column, $this->property, $this->join_type);
105 $inverse = (bool) $this->inverse_relationship;
106 $er_alias =
$qb->joinRelationshipTable($table_alias, $from_column, $this->property, $inverse, $this->join_type);
107 if (!empty($this->relationship_guid)) {
108 $guid_column = $inverse ?
'guid_two' :
'guid_one';
109 $qb->andWhere(
$qb->compare(
"{$er_alias}.{$guid_column}",
'=', $this->relationship_guid,
ELGG_VALUE_GUID));
112 $er_alias = $table_alias;
115 $column =
"{$er_alias}.time_created";
120 elgg_log(
"'{$this->property_type}' is not a valid entity property type. Sorting ignored.");
125 $column =
"CAST({$column} AS SIGNED)";
130 parent::prepare(
$qb, $table_alias);
Interfaces with the database to perform CRUD operations on annotations.
Extends QueryBuilder with clauses necessary to sort entity lists by entity properties.
prepare(QueryBuilder $qb, $table_alias=null)
{{Build an expression and/or apply it to an instance of query builder.Query builder Table aliasCompos...
Extends QueryBuilder with ORDER BY clauses.
Entity table database service.
Database abstraction query builder.
Relationships table database service.
Exception thrown if a value does not adhere to a defined valid data domain.
elgg_log($message, $level=\Psr\Log\LogLevel::NOTICE)
Log a message.