-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConjunctWhere.php
48 lines (37 loc) · 1.15 KB
/
ConjunctWhere.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
declare(strict_types = 1);
namespace Klapuch\Storage\Clauses;
final class ConjunctWhere implements ChainedWhere {
private $condition;
private $clause;
private $conjunct;
public function __construct(Clause $clause, string $conjunct, string $condition) {
$this->condition = $condition;
$this->clause = $clause;
$this->conjunct = $conjunct;
}
public function andWhere(string $condition): ChainedWhere {
return new self($this, 'AND', $condition);
}
public function orWhere(string $condition): ChainedWhere {
return new self($this, 'OR', $condition);
}
public function groupBy(array $columns): GroupBy {
return new AnsiGroupBy($this, $columns);
}
public function having(string $condition): Having {
return new AnsiHaving($this, $condition);
}
public function orderBy(array $orders): OrderBy {
return new AnsiOrderBy($this, $orders);
}
public function limit(int $limit): Limit {
return new AnsiLimit($this, $limit);
}
public function offset(int $offset): Offset {
return new AnsiOffset($this, $offset);
}
public function sql(): string {
return sprintf('%s %s %s', $this->clause->sql(), $this->conjunct, $this->condition);
}
}