50 if (!isset($this->property_type)) {
52 $this->property_type =
'attribute';
54 $this->property_type =
'metadata';
60 $from_column =
'guid';
64 $from_column =
'entity_guid';
67 $from_column =
'guid_one';
69 $from_column =
'guid_two';
74 switch ($this->property_type) {
76 $md_alias = $qb->
joinMetadataTable($table_alias, $from_column, $this->property, $this->join_type);
82 throw new DomainException(
"'{$this->property}' is not a valid entity attribute");
88 $e_alias = $table_alias;
91 $column =
"{$e_alias}.{$this->property}";
95 $an_alias = $qb->
joinAnnotationTable($table_alias, $from_column, $this->property, $this->join_type);
101 $er_alias = $qb->
joinRelationshipTable($table_alias, $from_column, $this->property, $this->inverse_relationship, $this->join_type);
102 if (!empty($this->relationship_guid)) {
103 $guid_column = $this->inverse_relationship ?
'guid_two' :
'guid_one';
104 $qb->andWhere($qb->
compare(
"{$er_alias}.{$guid_column}",
'=', $this->relationship_guid,
ELGG_VALUE_GUID));
107 $er_alias = $table_alias;
110 $column =
"{$er_alias}.time_created";
115 elgg_log(
"'{$this->property_type}' is not a valid entity property type. Sorting ignored.");
120 $column =
"CAST({$column} AS SIGNED)";
125 return parent::prepare($qb, $table_alias);
getTableName()
Returns the name of the primary table.
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 necesary to sort entity lists by entity properties.
joinEntitiesTable($from_alias= '', $from_column= 'guid', $join_type= 'inner', $joined_alias=null)
Join entity table from alias and return joined table alias.
elgg_log($message, $level=\Psr\Log\LogLevel::NOTICE)
Log a message.
const TABLE_RELATIONSHIPS
compare($x, $comparison, $y=null, $type=null, $case_sensitive=null)
Build value comparison clause.
joinAnnotationTable($from_alias= '', $from_column= 'guid', $name=null, $join_type= 'inner', $joined_alias=null)
Join annotations table from alias and return joined table alias.
Extends QueryBuilder with ORDER BY clauses.
joinMetadataTable($from_alias= '', $from_column= 'guid', $name=null, $join_type= 'inner', $joined_alias=null)
Join metadata table from alias and return joined table alias.
joinRelationshipTable($from_alias= '', $from_column= 'guid', $name=null, $inverse=false, $join_type= 'inner', $joined_alias=null)
Join relationship table from alias and return joined table alias.