Open Data Catalog v2.0.0
Query.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Drupal\common\Storage;
4 
5 use Contracts\SorterInterface;
6 use Contracts\ConditionerInterface;
7 use Contracts\OffsetterInterface;
8 use Contracts\LimiterInterface;
9 
13 class Query implements
14  SorterInterface,
15  ConditionerInterface,
16  OffsetterInterface,
17  LimiterInterface {
18 
24  public $collection;
25 
31  public $properties = [];
32 
44  public $conditions = [];
45 
46 
53  public $sorts = [];
54 
64  public $joins = [];
65 
71  public $limit = 500;
72 
78  public $offset = 0;
79 
85  public $count = FALSE;
86 
92  public $showDbColumns = FALSE;
93 
101  public function setCollectionToRetrieve($id) {
102  $this->collection = $id;
103  }
104 
111  public function filterByProperty($property) {
112  $this->properties[] = $property;
113  }
114 
123  public function conditionByIsEqualTo(string $property, string $value) {
124  $this->conditions[] = (object) [
125  'property' => $property,
126  'value' => $value,
127  'operator' => 'LIKE',
128  ];
129  }
130 
137  public function limitTo(int $number_of_items) {
138  $this->limit = $number_of_items;
139  }
140 
147  public function offsetBy(int $offset) {
148  $this->offset = $offset;
149  }
150 
157  public function sortByAscending(string $property) {
158  $this->sorts[] = (object) [
159  "property" => $property,
160  "order" => "asc",
161  ];
162  }
163 
170  public function sortByDescending(string $property) {
171  $this->sorts[] = (object) [
172  "property" => $property,
173  "order" => "desc",
174  ];
175  }
176 
182  public function count() {
183  $this->count = TRUE;
184  unset($this->limit);
185  }
186 
187 }
Drupal\common\Storage\Query\offsetBy
offsetBy(int $offset)
Definition: Query.php:147
Drupal\common\Storage\Query\$properties
$properties
Definition: Query.php:31
Drupal\common\Storage\Query\$joins
$joins
Definition: Query.php:64
Drupal\common\Storage\Query\sortByAscending
sortByAscending(string $property)
Definition: Query.php:157
Drupal\common\Storage\Query\$conditions
$conditions
Definition: Query.php:44
Drupal\common\Storage\Query\$sorts
$sorts
Definition: Query.php:53
Drupal\common\Storage\Query\$offset
$offset
Definition: Query.php:78
Drupal\common\Storage\Query\limitTo
limitTo(int $number_of_items)
Definition: Query.php:137
Drupal\common\Storage\Query\conditionByIsEqualTo
conditionByIsEqualTo(string $property, string $value)
Definition: Query.php:123
Drupal\common\Storage\Query\sortByDescending
sortByDescending(string $property)
Definition: Query.php:170
Drupal\common\Storage\Query\$count
$count
Definition: Query.php:85
Drupal\common\Storage\Query\count
count()
Definition: Query.php:182
Drupal\common\Storage\Query\$showDbColumns
$showDbColumns
Definition: Query.php:92
Drupal\common\Storage\Query
Definition: Query.php:13
Drupal\common\Storage\Query\setCollectionToRetrieve
setCollectionToRetrieve($id)
Definition: Query.php:101
Drupal\common\Storage
Definition: AbstractDatabaseTable.php:3
Drupal\common\Storage\Query\filterByProperty
filterByProperty($property)
Definition: Query.php:111
Drupal\common\Storage\Query\$collection
$collection
Definition: Query.php:24
Drupal\common\Storage\Query\$limit
$limit
Definition: Query.php:71