Elgg  Version master
RiverWhereClause.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Database\Clauses;
4 
6 
11 
15  public $ids;
16 
21 
25  public $action_types;
26 
30  public $views;
31 
36 
40  public $object_guids;
41 
45  public $target_guids;
46 
51 
56 
61 
65  public function prepare(QueryBuilder $qb, $table_alias = null) {
66  $alias = function ($column) use ($table_alias) {
67  return $table_alias ? "{$table_alias}.{$column}" : $column;
68  };
69 
70  $wheres = [];
71  $wheres[] = parent::prepare($qb, $table_alias);
72 
73  $types = new TypeSubtypeWhereClause();
74  $types->type_subtype_pairs = $this->type_subtype_pairs;
75  $wheres[] = $types->prepare($qb, $table_alias);
76 
77  $wheres[] = $qb->compare($alias('id'), '=', $this->ids, ELGG_VALUE_ID);
78  $wheres[] = $qb->compare($alias('annotation_id'), '=', $this->annotation_ids, ELGG_VALUE_ID);
79  $wheres[] = $qb->compare($alias('view'), '=', $this->views, ELGG_VALUE_STRING);
80  $wheres[] = $qb->compare($alias('action_type'), '=', $this->action_types, ELGG_VALUE_STRING);
81  $wheres[] = $qb->compare($alias('subject_guid'), '=', $this->subject_guids, ELGG_VALUE_GUID);
82  $wheres[] = $qb->compare($alias('object_guid'), '=', $this->object_guids, ELGG_VALUE_GUID);
83  $wheres[] = $qb->compare($alias('target_guid'), '=', $this->target_guids, ELGG_VALUE_GUID);
84  $wheres[] = $qb->between($alias('posted'), $this->created_after, $this->created_before, ELGG_VALUE_TIMESTAMP);
85 
86  return $qb->merge($wheres);
87  }
88 }
$column
Definition: add.php:10
const ELGG_VALUE_GUID
Definition: constants.php:113
Database abstraction query builder.
const ELGG_VALUE_ID
Definition: constants.php:114
Builds queries for matching river items against their properties.
compare(string $x, string $comparison, $y=null, string $type=null, bool $case_sensitive=null)
Build value comparison clause.
const ELGG_VALUE_TIMESTAMP
Definition: constants.php:115
Builds clauses for filtering entities by their type and subtype.
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
prepare(QueryBuilder $qb, $table_alias=null)
{}
between(string $x, $lower=null, $upper=null, string $type=null)
Build a between clause.