49 if (!isset($this->property_type)) {
51 $this->property_type =
'attribute';
53 $this->property_type =
'metadata';
59 $from_column =
'guid';
61 $from_column =
'guid_one';
63 $from_column =
'guid_two';
67 switch ($this->property_type) {
69 $md_alias = $qb->
joinMetadataTable($table_alias, $from_column, $this->property, $this->join_type);
81 $e_alias = $table_alias;
84 $column =
"{$e_alias}.{$this->property}";
87 case 'private_setting':
93 $an_alias = $qb->
joinAnnotationTable($table_alias, $from_column, $this->property, $this->join_type);
99 $er_alias = $qb->
joinRelationshipTable($table_alias, $from_column, $this->property, $this->inverse_relationship, $this->join_type);
100 if (!empty($this->relationship_guid)) {
101 $guid_column = $this->inverse_relationship ?
'guid_two' :
'guid_one';
102 $qb->andWhere($qb->
compare(
"{$er_alias}.{$guid_column}",
'=', $this->relationship_guid,
ELGG_VALUE_GUID));
105 $er_alias = $table_alias;
107 $column =
"{$er_alias}.time_created";
112 elgg_log(
"'{$this->property_type}' is not a valid entity property type. Sorting ignored.");
117 $column =
"CAST({$column} AS SIGNED)";
122 return parent::prepare($qb, $table_alias);
getTableName()
Returns the name of the primary table.
prepare(QueryBuilder $qb, $table_alias=null)
{}
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.
joinPrivateSettingsTable($from_alias= '', $from_column= 'guid', $name=null, $join_type= 'inner', $joined_alias=null)
Join private settings table from alias and return joined table alias.
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.