Elgg  Version master
RiverWhereClause.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Database\Clauses;
4 
5 use DateTime;
8 use ElggEntity;
9 
14 
18  public $ids;
19 
24 
28  public $action_types;
29 
33  public $views;
34 
39 
43  public $object_guids;
44 
48  public $target_guids;
49 
54 
59 
64 
68  public function prepare(QueryBuilder $qb, $table_alias = null) {
69  $alias = function ($column) use ($table_alias) {
70  return $table_alias ? "{$table_alias}.{$column}" : $column;
71  };
72 
73  $wheres = [];
74  $wheres[] = parent::prepare($qb, $table_alias);
75 
76  $types = new TypeSubtypeWhereClause();
77  $types->type_subtype_pairs = $this->type_subtype_pairs;
78  $wheres[] = $types->prepare($qb, $table_alias);
79 
80  $wheres[] = $qb->compare($alias('id'), '=', $this->ids, ELGG_VALUE_ID);
81  $wheres[] = $qb->compare($alias('annotation_id'), '=', $this->annotation_ids, ELGG_VALUE_ID);
82  $wheres[] = $qb->compare($alias('view'), '=', $this->views, ELGG_VALUE_STRING);
83  $wheres[] = $qb->compare($alias('action_type'), '=', $this->action_types, ELGG_VALUE_STRING);
84  $wheres[] = $qb->compare($alias('subject_guid'), '=', $this->subject_guids, ELGG_VALUE_GUID);
85  $wheres[] = $qb->compare($alias('object_guid'), '=', $this->object_guids, ELGG_VALUE_GUID);
86  $wheres[] = $qb->compare($alias('target_guid'), '=', $this->target_guids, ELGG_VALUE_GUID);
87  $wheres[] = $qb->between($alias('posted'), $this->created_after, $this->created_before, ELGG_VALUE_TIMESTAMP);
88 
89  return $qb->merge($wheres);
90  }
91 }
$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:12
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.