54 if (!isset($this->property_type)) {
56 $this->property_type =
'attribute';
58 $this->property_type =
'metadata';
64 $from_column =
'guid';
68 $from_column =
'entity_guid';
71 $from_column =
'guid_one';
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");
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);
getTableName()
Returns the name of the primary table.
joinAnnotationTable(string $from_alias= '', string $from_column= 'guid', $name=null,?string $join_type= 'inner', string $joined_alias=null)
Join annotations table from alias and return joined table alias.
prepare(QueryBuilder $qb, $table_alias=null)
{}
Exception thrown if a value does not adhere to a defined valid data domain.
Database abstraction query builder.
Extends QueryBuilder with clauses necessary to sort entity lists by entity properties.
elgg_log($message, $level=\Psr\Log\LogLevel::NOTICE)
Log a message.
compare(string $x, string $comparison, $y=null, string $type=null, bool $case_sensitive=null)
Build value comparison clause.
joinEntitiesTable(string $from_alias= '', string $from_column= 'guid',?string $join_type= 'inner', string $joined_alias=null)
Join entity table from alias and return joined table alias.
joinRelationshipTable(string $from_alias= '', string $from_column= 'guid', $name=null, bool $inverse=false,?string $join_type= 'inner', string $joined_alias=null)
Join relationship table from alias and return joined table alias.
Extends QueryBuilder with ORDER BY clauses.
joinMetadataTable(string $from_alias= '', string $from_column= 'guid', $name=null,?string $join_type= 'inner', string $joined_alias=null)
Join metadata table from alias and return joined table alias.