Elgg  Version 6.1
MetadataWhereClause.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Database\Clauses;
4 
6 
11 
15  public $ids;
16 
20  public $entity_guids;
21 
25  public $names;
26 
30  public $comparison = '=';
31 
35  public $values;
36 
41 
45  public $case_sensitive = true;
46 
51 
56 
60  public function prepare(QueryBuilder $qb, $table_alias = null) {
61  $alias = function ($column) use ($table_alias) {
62  return $table_alias ? "{$table_alias}.{$column}" : $column;
63  };
64 
65  $wheres = [];
66  $wheres[] = parent::prepare($qb, $table_alias);
67 
68  $wheres[] = $qb->compare($alias('id'), '=', $this->ids, ELGG_VALUE_ID);
69  $wheres[] = $qb->compare($alias('name'), '=', $this->names, ELGG_VALUE_STRING);
70  $wheres[] = $qb->compare($alias('value'), $this->comparison, $this->values, $this->value_type, $this->case_sensitive);
71  $wheres[] = $qb->compare($alias('entity_guid'), '=', $this->entity_guids, ELGG_VALUE_GUID);
72  $wheres[] = $qb->between($alias('time_created'), $this->created_after, $this->created_before, ELGG_VALUE_TIMESTAMP);
73 
74  return $qb->merge($wheres);
75  }
76 }
$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
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 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
prepare(QueryBuilder $qb, $table_alias=null)
{}
$qb
Definition: queue.php:12
Builds clauses for filtering entities by properties in metadata table.
between(string $x, $lower=null, $upper=null, string $type=null)
Build a between clause.