Elgg  Version 5.1
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 
71  public $enabled;
72 
77 
82 
86  public $viewer_guid;
87 
91  public function prepare(QueryBuilder $qb, $table_alias = '') {
92 
93  $alias = function ($column) use ($table_alias) {
94  return $table_alias ? "{$table_alias}.{$column}" : $column;
95  };
96 
97  $wheres = [];
98  $wheres[] = parent::prepare($qb, $table_alias);
99 
100  $access = new AccessWhereClause();
101  $access->use_enabled_clause = $this->use_enabled_clause;
102  $access->ignore_access = $this->ignore_access;
103  $access->viewer_guid = $this->viewer_guid;
104  $wheres[] = $access->prepare($qb, $table_alias);
105 
107  $type->type_subtype_pairs = $this->type_subtype_pairs;
108  $wheres[] = $type->prepare($qb, $table_alias);
109 
110  $wheres[] = $qb->compare($alias('guid'), '=', $this->guids, ELGG_VALUE_GUID);
111  $wheres[] = $qb->compare($alias('owner_guid'), '=', $this->owner_guids, ELGG_VALUE_GUID);
112  $wheres[] = $qb->compare($alias('container_guid'), '=', $this->container_guids, ELGG_VALUE_GUID);
113  $wheres[] = $qb->between($alias('time_created'), $this->created_after, $this->created_before, ELGG_VALUE_TIMESTAMP);
114  $wheres[] = $qb->between($alias('time_updated'), $this->updated_after, $this->updated_before, ELGG_VALUE_TIMESTAMP);
115  $wheres[] = $qb->between($alias('last_action'), $this->last_action_after, $this->last_action_before, ELGG_VALUE_TIMESTAMP);
116  $wheres[] = $qb->compare($alias('enabled'), '=', $this->enabled, ELGG_VALUE_STRING);
117  $wheres[] = $qb->compare($alias('access_id'), '=', $this->access_ids, ELGG_VALUE_ID);
118 
119  return $qb->merge($wheres);
120  }
121 
128  public static function factory(QueryOptions $options) {
129  $where = new static();
130  $where->guids = $options->guids;
131  $where->owner_guids = $options->owner_guids;
132  $where->container_guids = $options->container_guids;
133  $where->type_subtype_pairs = $options->type_subtype_pairs;
134  $where->created_after = $options->created_after;
135  $where->created_before = $options->created_before;
136  $where->updated_after = $options->updated_after;
137  $where->updated_before = $options->updated_before;
138  $where->last_action_after = $options->last_action_after;
139  $where->last_action_before = $options->last_action_before;
140  $where->access_ids = $options->access_ids;
141 
142  return $where;
143  }
144 }
if(elgg_view_exists("widgets/{$widget->handler}/edit")) $access
Definition: save.php:25
$column
Definition: add.php:10
const ELGG_VALUE_GUID
Definition: constants.php:113
Database abstraction query builder.
$type
Definition: delete.php:22
prepare(QueryBuilder $qb, $table_alias= '')
{}
const ELGG_VALUE_ID
Definition: constants.php:114
$options
Elgg admin footer.
Definition: footer.php:6
Builds queries for filtering entities by their properties in the entities table.
between($x, $lower=null, $upper=null, $type=null)
Build a between clause.
compare($x, $comparison, $y=null, $type=null, $case_sensitive=null)
Build value comparison clause.
static factory(QueryOptions $options)
Build new clause from options.
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:11
Builds queries to restrict access.