@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | * @param string|Select $table |
113 | 113 | * @param string[] $columns |
114 | 114 | */ |
115 | - public function __construct (DB $db, $table, array $columns) { |
|
115 | + public function __construct(DB $db, $table, array $columns) { |
|
116 | 116 | parent::__construct($db); |
117 | 117 | if ($table instanceof Select) { |
118 | 118 | $this->table = $table->toSubquery(); |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | * @param array $args |
133 | 133 | * @return Statement |
134 | 134 | */ |
135 | - public function __invoke (array $args = []) { |
|
135 | + public function __invoke(array $args = []) { |
|
136 | 136 | return $this->execute($args); |
137 | 137 | } |
138 | 138 | |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * |
142 | 142 | * @return string |
143 | 143 | */ |
144 | - final public function __toString () { |
|
144 | + final public function __toString() { |
|
145 | 145 | return $this->alias; |
146 | 146 | } |
147 | 147 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * @param array $args Execution arguments. |
152 | 152 | * @return int |
153 | 153 | */ |
154 | - public function count (array $args = []): int { |
|
154 | + public function count(array $args = []): int { |
|
155 | 155 | $clone = clone $this; |
156 | 156 | $clone->_columns = 'COUNT(*)'; |
157 | 157 | $clone->_order = ''; |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | * @param array $args |
165 | 165 | * @return Statement |
166 | 166 | */ |
167 | - public function execute (array $args = []) { |
|
167 | + public function execute(array $args = []) { |
|
168 | 168 | if (empty($args)) { |
169 | 169 | return $this->db->query($this->toSql()); |
170 | 170 | } |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | * @param array $args Execution arguments. |
180 | 180 | * @return array |
181 | 181 | */ |
182 | - public function getAll (array $args = []): array { |
|
182 | + public function getAll(array $args = []): array { |
|
183 | 183 | return iterator_to_array($this->fetcher->__invoke($this->execute($args))); |
184 | 184 | } |
185 | 185 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * @param array $args Execution arguments. |
193 | 193 | * @return Generator |
194 | 194 | */ |
195 | - public function getEach (array $args = []) { |
|
195 | + public function getEach(array $args = []) { |
|
196 | 196 | yield from $this->fetcher->__invoke($this->execute($args)); |
197 | 197 | } |
198 | 198 | |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | * @param array $args |
205 | 205 | * @return mixed |
206 | 206 | */ |
207 | - public function getFirst (array $args = []) { |
|
207 | + public function getFirst(array $args = []) { |
|
208 | 208 | return $this->getEach($args)->current(); |
209 | 209 | } |
210 | 210 | |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | * |
216 | 216 | * @return Generator |
217 | 217 | */ |
218 | - public function getIterator () { |
|
218 | + public function getIterator() { |
|
219 | 219 | yield from $this->getEach(); |
220 | 220 | } |
221 | 221 | |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | * @param string $column |
226 | 226 | * @return $this |
227 | 227 | */ |
228 | - public function group (string $column) { |
|
228 | + public function group(string $column) { |
|
229 | 229 | if (!strlen($this->_group)) { |
230 | 230 | $this->_group = " GROUP BY {$column}"; |
231 | 231 | } |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * @param string $condition |
242 | 242 | * @return $this |
243 | 243 | */ |
244 | - public function having (string $condition) { |
|
244 | + public function having(string $condition) { |
|
245 | 245 | if (!strlen($this->_having)) { |
246 | 246 | $this->_having = " HAVING {$condition}"; |
247 | 247 | } |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | * @param bool $all |
259 | 259 | * @return $this |
260 | 260 | */ |
261 | - public function intersect (Select $select, $all = false) { |
|
261 | + public function intersect(Select $select, $all = false) { |
|
262 | 262 | $select = clone $select; |
263 | 263 | $select->_order = ''; |
264 | 264 | $select->_limit = ''; |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | * |
277 | 277 | * @return Predicate |
278 | 278 | */ |
279 | - public function isEmpty () { |
|
279 | + public function isEmpty() { |
|
280 | 280 | return new Predicate("NOT EXISTS ({$this->toSql()})"); |
281 | 281 | } |
282 | 282 | |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | * |
286 | 286 | * @return Predicate |
287 | 287 | */ |
288 | - public function isNotEmpty () { |
|
288 | + public function isNotEmpty() { |
|
289 | 289 | return new Predicate("EXISTS ({$this->toSql()})"); |
290 | 290 | } |
291 | 291 | |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | * @param string $type |
298 | 298 | * @return $this |
299 | 299 | */ |
300 | - public function join ($table, string $condition, string $type = 'INNER') { |
|
300 | + public function join($table, string $condition, string $type = 'INNER') { |
|
301 | 301 | if ($table instanceof Select) { |
302 | 302 | $table = $table->toSubquery(); |
303 | 303 | } |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | * @param int $offset |
313 | 313 | * @return $this |
314 | 314 | */ |
315 | - public function limit (int $limit, int $offset = 0) { |
|
315 | + public function limit(int $limit, int $offset = 0) { |
|
316 | 316 | if ($limit == 0) { |
317 | 317 | $this->_limit = ''; |
318 | 318 | } |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | * @param mixed $offset Ordinal or reference name. |
332 | 332 | * @return bool |
333 | 333 | */ |
334 | - public function offsetExists ($offset): bool { |
|
334 | + public function offsetExists($offset): bool { |
|
335 | 335 | return isset($this->refs[$offset]); |
336 | 336 | } |
337 | 337 | |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | * @param mixed $offset Ordinal or reference name. |
342 | 342 | * @return Column |
343 | 343 | */ |
344 | - public function offsetGet ($offset) { |
|
344 | + public function offsetGet($offset) { |
|
345 | 345 | return $this->refs[$offset]; |
346 | 346 | } |
347 | 347 | |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | * @param string $order |
352 | 352 | * @return $this |
353 | 353 | */ |
354 | - public function order (string $order) { |
|
354 | + public function order(string $order) { |
|
355 | 355 | if (strlen($order)) { |
356 | 356 | $order = " ORDER BY {$order}"; |
357 | 357 | } |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | /** |
363 | 363 | * @return Statement |
364 | 364 | */ |
365 | - public function prepare () { |
|
365 | + public function prepare() { |
|
366 | 366 | return $this->db->prepare($this->toSql()); |
367 | 367 | } |
368 | 368 | |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | * @param string $alias |
371 | 371 | * @return $this |
372 | 372 | */ |
373 | - public function setAlias (string $alias) { |
|
373 | + public function setAlias(string $alias) { |
|
374 | 374 | $this->alias = $alias; |
375 | 375 | foreach ($this->refs as $k => $column) { |
376 | 376 | $this->refs[$k] = $column->setQualifier($alias); |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | * @param string[] $columns |
385 | 385 | * @return $this |
386 | 386 | */ |
387 | - public function setColumns (array $columns) { |
|
387 | + public function setColumns(array $columns) { |
|
388 | 388 | $this->refs = []; |
389 | 389 | $_columns = []; |
390 | 390 | $i = 0; |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | * @param Closure $fetcher |
414 | 414 | * @return $this |
415 | 415 | */ |
416 | - public function setFetcher (Closure $fetcher) { |
|
416 | + public function setFetcher(Closure $fetcher) { |
|
417 | 417 | $this->fetcher = $fetcher; |
418 | 418 | return $this; |
419 | 419 | } |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | * |
424 | 424 | * @return string |
425 | 425 | */ |
426 | - public function toSql (): string { |
|
426 | + public function toSql(): string { |
|
427 | 427 | $sql = "SELECT {$this->_columns} FROM {$this->table}"; |
428 | 428 | $sql .= $this->_join; |
429 | 429 | $sql .= $this->_where; |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | * |
441 | 441 | * @return string |
442 | 442 | */ |
443 | - public function toSubquery (): string { |
|
443 | + public function toSubquery(): string { |
|
444 | 444 | return "({$this->toSql()}) AS {$this->alias}"; |
445 | 445 | } |
446 | 446 | |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | * @param bool $all |
452 | 452 | * @return $this |
453 | 453 | */ |
454 | - public function union (Select $select, $all = false) { |
|
454 | + public function union(Select $select, $all = false) { |
|
455 | 455 | $select = clone $select; |
456 | 456 | $select->_order = ''; |
457 | 457 | $select->_limit = ''; |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | * @param string $condition |
471 | 471 | * @return $this |
472 | 472 | */ |
473 | - public function where (string $condition) { |
|
473 | + public function where(string $condition) { |
|
474 | 474 | if (!strlen($this->_where)) { |
475 | 475 | $this->_where = " WHERE {$condition}"; |
476 | 476 | } |