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 
71  public $enabled;
72 
76  public $deleted;
77 
82 
87 
92 
96  public $viewer_guid;
97 
101  public function prepare(QueryBuilder $qb, $table_alias = '') {
102 
103  $alias = function ($column) use ($table_alias) {
104  return $table_alias ? "{$table_alias}.{$column}" : $column;
105  };
106 
107  $wheres = [];
108  $wheres[] = parent::prepare($qb, $table_alias);
109 
110  $access = new AccessWhereClause();
111  $access->use_enabled_clause = $this->use_enabled_clause;
112  $access->use_deleted_clause = $this->use_deleted_clause;
113  $access->ignore_access = $this->ignore_access;
114  $access->viewer_guid = $this->viewer_guid;
115  $wheres[] = $access->prepare($qb, $table_alias);
116 
118  $type->type_subtype_pairs = $this->type_subtype_pairs;
119  $wheres[] = $type->prepare($qb, $table_alias);
120 
121  $wheres[] = $qb->compare($alias('guid'), '=', $this->guids, ELGG_VALUE_GUID);
122  $wheres[] = $qb->compare($alias('owner_guid'), '=', $this->owner_guids, ELGG_VALUE_GUID);
123  $wheres[] = $qb->compare($alias('container_guid'), '=', $this->container_guids, ELGG_VALUE_GUID);
124  $wheres[] = $qb->between($alias('time_created'), $this->created_after, $this->created_before, ELGG_VALUE_TIMESTAMP);
125  $wheres[] = $qb->between($alias('time_updated'), $this->updated_after, $this->updated_before, ELGG_VALUE_TIMESTAMP);
126  $wheres[] = $qb->between($alias('last_action'), $this->last_action_after, $this->last_action_before, ELGG_VALUE_TIMESTAMP);
127  $wheres[] = $qb->compare($alias('enabled'), '=', $this->enabled, ELGG_VALUE_STRING);
128  $wheres[] = $qb->compare($alias('deleted'), '=', $this->deleted, ELGG_VALUE_STRING);
129  $wheres[] = $qb->compare($alias('access_id'), '=', $this->access_ids, ELGG_VALUE_ID);
130 
131  return $qb->merge($wheres);
132  }
133 
140  public static function factory(QueryOptions $options) {
141  $where = new static();
142  $where->guids = $options->guids;
143  $where->owner_guids = $options->owner_guids;
144  $where->container_guids = $options->container_guids;
145  $where->type_subtype_pairs = $options->type_subtype_pairs;
146  $where->created_after = $options->created_after;
147  $where->created_before = $options->created_before;
148  $where->updated_after = $options->updated_after;
149  $where->updated_before = $options->updated_before;
150  $where->last_action_after = $options->last_action_after;
151  $where->last_action_before = $options->last_action_before;
152  $where->access_ids = $options->access_ids;
153 
154  return $where;
155  }
156 }
if(elgg_view_exists("widgets/{$widget->handler}/edit")) $access
Definition: save.php:19
$column
Definition: add.php:10
const ELGG_VALUE_GUID
Definition: constants.php:113
Database abstraction query builder.
$type
Definition: delete.php:21
prepare(QueryBuilder $qb, $table_alias= '')
{}
const ELGG_VALUE_ID
Definition: constants.php:114
if($who_can_change_language=== 'nobody') elseif($who_can_change_language=== 'admin_only'&&!elgg_is_admin_logged_in()) $options
Definition: language.php:20
Builds queries for filtering entities by their properties in the entities table.
compare(string $x, string $comparison, $y=null, string $type=null, bool $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:12
between(string $x, $lower=null, $upper=null, string $type=null)
Build a between clause.
Builds queries to restrict access.