Elgg  Version master
EntityWhereClause.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Database\Clauses;
4 
7 
12 
16  public $guids;
17 
21  public $owner_guids;
22 
27 
32 
36  public $access_ids;
37 
42 
47 
52 
57 
62 
67 
72 
77 
81  public $enabled;
82 
86  public $deleted;
87 
92 
97 
102 
106  public $viewer_guid;
107 
111  public function prepare(QueryBuilder $qb, $table_alias = '') {
112 
113  $alias = function ($column) use ($table_alias) {
114  return $table_alias ? "{$table_alias}.{$column}" : $column;
115  };
116 
117  $wheres = [];
118  $wheres[] = parent::prepare($qb, $table_alias);
119 
120  $access = new AccessWhereClause();
121  $access->use_enabled_clause = $this->use_enabled_clause;
122  $access->use_deleted_clause = $this->use_deleted_clause;
123  $access->ignore_access = $this->ignore_access;
124  $access->viewer_guid = $this->viewer_guid;
125  $wheres[] = $access->prepare($qb, $table_alias);
126 
128  $type->type_subtype_pairs = $this->type_subtype_pairs;
129  $wheres[] = $type->prepare($qb, $table_alias);
130 
131  $wheres[] = $qb->compare($alias('guid'), '=', $this->guids, ELGG_VALUE_GUID);
132  $wheres[] = $qb->compare($alias('owner_guid'), '=', $this->owner_guids, ELGG_VALUE_GUID);
133  $wheres[] = $qb->compare($alias('container_guid'), '=', $this->container_guids, ELGG_VALUE_GUID);
134  $wheres[] = $qb->between($alias('time_created'), $this->created_after, $this->created_before, ELGG_VALUE_TIMESTAMP);
135  $wheres[] = $qb->between($alias('time_updated'), $this->updated_after, $this->updated_before, ELGG_VALUE_TIMESTAMP);
136  $wheres[] = $qb->between($alias('last_action'), $this->last_action_after, $this->last_action_before, ELGG_VALUE_TIMESTAMP);
137  $wheres[] = $qb->between($alias('time_deleted'), $this->deleted_after, $this->deleted_before, ELGG_VALUE_TIMESTAMP);
138  $wheres[] = $qb->compare($alias('enabled'), '=', $this->enabled, ELGG_VALUE_STRING);
139  $wheres[] = $qb->compare($alias('deleted'), '=', $this->deleted, ELGG_VALUE_STRING);
140  $wheres[] = $qb->compare($alias('access_id'), '=', $this->access_ids, ELGG_VALUE_ID);
141 
142  return $qb->merge($wheres);
143  }
144 
151  public static function factory(QueryOptions $options) {
152  $where = new static();
153  $where->guids = $options->guids;
154  $where->owner_guids = $options->owner_guids;
155  $where->container_guids = $options->container_guids;
156  $where->type_subtype_pairs = $options->type_subtype_pairs;
157  $where->created_after = $options->created_after;
158  $where->created_before = $options->created_before;
159  $where->updated_after = $options->updated_after;
160  $where->updated_before = $options->updated_before;
161  $where->last_action_after = $options->last_action_after;
162  $where->last_action_before = $options->last_action_before;
163  $where->deleted_after = $options->deleted_after;
164  $where->deleted_before = $options->deleted_before;
165  $where->access_ids = $options->access_ids;
166 
167  return $where;
168  }
169 }
$type
Definition: delete.php:21
$column
Definition: add.php:10
Builds queries to restrict access.
Builds queries for filtering entities by their properties in the entities table.
prepare(QueryBuilder $qb, $table_alias='')
{{Build an expression and/or apply it to an instance of query builder.Query builder Table aliasCompos...
static factory(QueryOptions $options)
Build new clause from options.
Builds clauses for filtering entities by their type and subtype.
Builds a clause from closure or composite expression.
Definition: WhereClause.php:11
Database abstraction query builder.
const ELGG_VALUE_STRING
Definition: constants.php:112
const ELGG_VALUE_ID
Definition: constants.php:114
const ELGG_VALUE_GUID
Definition: constants.php:113
const ELGG_VALUE_TIMESTAMP
Definition: constants.php:115
if($who_can_change_language==='nobody') elseif($who_can_change_language==='admin_only' &&!elgg_is_admin_logged_in()) $options
Definition: language.php:20
$qb
Definition: queue.php:14
if(elgg_view_exists("widgets/{$widget->handler}/edit")) $access
Definition: save.php:19