Elgg  Version master
RelationshipWhereClause.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Database\Clauses;
4 
6 
11 
15  public $ids;
16 
20  public $names;
21 
26 
30  public $object_guids;
31 
36 
41 
45  public $inverse;
46 
50  public $join_on = 'guid';
51 
55  public function prepare(QueryBuilder $qb, $table_alias = null) {
56  $alias = function ($column) use ($table_alias) {
57  return $table_alias ? "{$table_alias}.{$column}" : $column;
58  };
59 
60  $wheres = [];
61 
62  $wheres[] = parent::prepare($qb, $table_alias);
63 
64  $wheres[] = $qb->compare($alias('id'), '=', $this->ids, ELGG_VALUE_ID);
65  $wheres[] = $qb->compare($alias('relationship'), '=', $this->names, ELGG_VALUE_STRING);
66  $wheres[] = $qb->compare($alias('guid_one'), '=', $this->subject_guids, ELGG_VALUE_GUID);
67  $wheres[] = $qb->compare($alias('guid_two'), '=', $this->object_guids, ELGG_VALUE_GUID);
68  $wheres[] = $qb->between($alias('time_created'), $this->created_after, $this->created_before, ELGG_VALUE_TIMESTAMP);
69 
70  return $qb->merge($wheres);
71  }
72 }
$column
Definition: add.php:10
const ELGG_VALUE_GUID
Definition: constants.php:113
Builds clauses for filtering entities by their properties in entity_relationships table...
Database abstraction query builder.
const ELGG_VALUE_ID
Definition: constants.php:114
compare(string $x, string $comparison, $y=null, string $type=null, bool $case_sensitive=null)
Build value comparison clause.
prepare(QueryBuilder $qb, $table_alias=null)
{}
const ELGG_VALUE_TIMESTAMP
Definition: constants.php:115
Builds a clause from closure or composite expression.
Definition: WhereClause.php:11
merge($parts=null, $boolean= 'AND')
Merges multiple composite expressions with a boolean.
const ELGG_VALUE_STRING
Definition: constants.php:112
$qb
Definition: queue.php:12
between(string $x, $lower=null, $upper=null, string $type=null)
Build a between clause.