1 | <?php |
||
13 | class QueryBuilder |
||
14 | { |
||
15 | /** |
||
16 | * @var Query |
||
17 | */ |
||
18 | private $query; |
||
19 | |||
20 | 53 | public function __construct() |
|
24 | |||
25 | 53 | public function select(AbstractSelect ...$selects): self |
|
33 | |||
34 | 53 | public function from(AbstractFrom $from): self |
|
40 | |||
41 | 19 | public function where(AbstractCompare $where): self |
|
47 | |||
48 | 1 | public function andWhere(AbstractCompare $where, bool $wrapPrevious = false): self |
|
54 | |||
55 | 1 | public function orWhere(AbstractCompare $where, bool $wrapPrevious = false): self |
|
61 | |||
62 | 4 | public function groupBy(AbstractGroupBy $groupBy): self |
|
68 | |||
69 | 19 | public function having(AbstractCompare $having): self |
|
75 | |||
76 | 1 | public function andHaving(AbstractCompare $having, bool $wrapPrevious = false): self |
|
82 | |||
83 | 1 | public function orHaving(AbstractCompare $having, bool $wrapPrevious = false): self |
|
89 | |||
90 | 1 | private function addOrUpdateWhere(AbstractCompare $where, Operator $operator, bool $wrapPrevious) |
|
91 | { |
||
92 | 1 | $this->query->setWhere($this->createCompositeCompare( |
|
93 | 1 | $where, |
|
94 | 1 | $operator, |
|
95 | 1 | $wrapPrevious, |
|
96 | 1 | $this->query->getWhere() |
|
97 | )); |
||
98 | 1 | } |
|
99 | |||
100 | 1 | private function addOrUpdateHaving(AbstractCompare $having, Operator $operator, bool $wrapPrevious) |
|
101 | { |
||
102 | 1 | $this->query->setHaving($this->createCompositeCompare( |
|
103 | 1 | $having, |
|
104 | 1 | $operator, |
|
105 | 1 | $wrapPrevious, |
|
106 | 1 | $this->query->getHaving() |
|
107 | )); |
||
108 | 1 | } |
|
109 | |||
110 | 1 | private function createCompositeCompare( |
|
122 | |||
123 | 4 | public function orderBy(AbstractOrderBy $orderBy): self |
|
129 | |||
130 | 2 | public function limit(int $limit): self |
|
136 | |||
137 | 2 | public function offset(int $offset): self |
|
143 | |||
144 | 19 | public function setParameters(array $parameters): self |
|
150 | |||
151 | 53 | public function getQuery(): Query |
|
155 | } |
||
156 |