1 | <?php declare(strict_types=1); |
||
20 | class State { |
||
21 | // -------------------------------------------------------------------------- |
||
22 | // ! SQL Clause Strings |
||
23 | // -------------------------------------------------------------------------- |
||
24 | |||
25 | /** |
||
26 | * Compiled 'select' clause |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $selectString = ''; |
||
30 | |||
31 | /** |
||
32 | * Compiled 'from' clause |
||
33 | * @var string |
||
34 | */ |
||
35 | protected $fromString = ''; |
||
36 | |||
37 | /** |
||
38 | * Compiled arguments for insert / update |
||
39 | * @var string |
||
40 | */ |
||
41 | protected $setString = ''; |
||
42 | |||
43 | /** |
||
44 | * Order by clause |
||
45 | * @var string |
||
46 | */ |
||
47 | protected $orderString = ''; |
||
48 | |||
49 | /** |
||
50 | * Group by clause |
||
51 | * @var string |
||
52 | */ |
||
53 | protected $groupString = ''; |
||
54 | |||
55 | // -------------------------------------------------------------------------- |
||
56 | // ! SQL Clause Arrays |
||
57 | // -------------------------------------------------------------------------- |
||
58 | |||
59 | /** |
||
60 | * Keys for insert/update statement |
||
61 | * @var array |
||
62 | */ |
||
63 | protected $setArrayKeys = []; |
||
64 | |||
65 | /** |
||
66 | * Key/val pairs for order by clause |
||
67 | * @var array |
||
68 | */ |
||
69 | protected $orderArray = []; |
||
70 | |||
71 | /** |
||
72 | * Key/val pairs for group by clause |
||
73 | * @var array |
||
74 | */ |
||
75 | protected $groupArray = []; |
||
76 | |||
77 | // -------------------------------------------------------------------------- |
||
78 | // ! Other Class vars |
||
79 | // -------------------------------------------------------------------------- |
||
80 | |||
81 | /** |
||
82 | * Values to apply to prepared statements |
||
83 | * @var array |
||
84 | */ |
||
85 | protected $values = []; |
||
86 | |||
87 | /** |
||
88 | * Values to apply to where clauses in prepared statements |
||
89 | * @var array |
||
90 | */ |
||
91 | protected $whereValues = []; |
||
92 | |||
93 | /** |
||
94 | * Value for limit string |
||
95 | * @var int |
||
96 | */ |
||
97 | protected $limit; |
||
98 | |||
99 | /** |
||
100 | * Value for offset in limit string |
||
101 | * @var string|false |
||
102 | */ |
||
103 | protected $offset = FALSE; |
||
104 | |||
105 | /** |
||
106 | * Query component order mapping |
||
107 | * for complex select queries |
||
108 | * |
||
109 | * Format: |
||
110 | * array( |
||
111 | * 'type' => 'where', |
||
112 | * 'conjunction' => ' AND ', |
||
113 | * 'string' => 'k=?' |
||
114 | * ) |
||
115 | * |
||
116 | * @var array |
||
117 | */ |
||
118 | protected $queryMap = []; |
||
119 | |||
120 | /** |
||
121 | * Map for having clause |
||
122 | * @var array |
||
123 | */ |
||
124 | protected $havingMap = []; |
||
125 | |||
126 | // -------------------------------------------------------------------------- |
||
127 | |||
128 | /** |
||
129 | * @param string $str |
||
130 | * @return State |
||
131 | */ |
||
132 | public function setSelectString(string $str): self |
||
137 | |||
138 | /** |
||
139 | * @return string |
||
140 | */ |
||
141 | public function getSelectString(): string |
||
145 | |||
146 | /** |
||
147 | * @param string $str |
||
148 | * @return State |
||
149 | */ |
||
150 | public function appendSelectString(string $str): self |
||
155 | |||
156 | /** |
||
157 | * @return string |
||
158 | */ |
||
159 | public function getFromString(): string |
||
163 | |||
164 | /** |
||
165 | * @param string $fromString |
||
166 | * @return State |
||
167 | */ |
||
168 | public function setFromString(string $fromString): State |
||
173 | |||
174 | /** |
||
175 | * @return string |
||
176 | */ |
||
177 | public function getSetString(): string |
||
181 | |||
182 | /** |
||
183 | * @param string $setString |
||
184 | * @return State |
||
185 | */ |
||
186 | public function setSetString(string $setString): State |
||
191 | |||
192 | /** |
||
193 | * @return string |
||
194 | */ |
||
195 | public function getOrderString(): string |
||
199 | |||
200 | /** |
||
201 | * @param string $orderString |
||
202 | * @return State |
||
203 | */ |
||
204 | public function setOrderString(string $orderString): State |
||
209 | |||
210 | /** |
||
211 | * @return string |
||
212 | */ |
||
213 | public function getGroupString(): string |
||
217 | |||
218 | /** |
||
219 | * @param string $groupString |
||
220 | * @return State |
||
221 | */ |
||
222 | public function setGroupString(string $groupString): State |
||
227 | |||
228 | /** |
||
229 | * @return array |
||
230 | */ |
||
231 | public function getSetArrayKeys(): array |
||
235 | |||
236 | /** |
||
237 | * @param array $setArrayKeys |
||
238 | * @return State |
||
239 | */ |
||
240 | public function appendSetArrayKeys(array $setArrayKeys): State |
||
245 | |||
246 | /** |
||
247 | * @param array $setArrayKeys |
||
248 | * @return State |
||
249 | */ |
||
250 | public function setSetArrayKeys(array $setArrayKeys): State |
||
255 | |||
256 | /** |
||
257 | * @return array |
||
258 | */ |
||
259 | public function getOrderArray(): array |
||
263 | |||
264 | /** |
||
265 | * @param string $key |
||
266 | * @param mixed $orderArray |
||
267 | * @return State |
||
268 | */ |
||
269 | public function setOrderArray(string $key, $orderArray): State |
||
274 | |||
275 | /** |
||
276 | * @return array |
||
277 | */ |
||
278 | public function getGroupArray(): array |
||
282 | |||
283 | /** |
||
284 | * @param array $groupArray |
||
285 | * @return State |
||
286 | */ |
||
287 | public function setGroupArray(array $groupArray): State |
||
292 | |||
293 | /** |
||
294 | * @param string $groupArray |
||
295 | * @return State |
||
296 | */ |
||
297 | public function appendGroupArray(string $groupArray): State |
||
302 | |||
303 | /** |
||
304 | * @return array |
||
305 | */ |
||
306 | public function getValues(): array |
||
310 | |||
311 | /** |
||
312 | * @param array $values |
||
313 | * @return State |
||
314 | */ |
||
315 | public function appendValues(array $values): State |
||
320 | |||
321 | /** |
||
322 | * @return array |
||
323 | */ |
||
324 | public function getWhereValues(): array |
||
328 | |||
329 | /** |
||
330 | * @param mixed $val |
||
331 | * @return State |
||
332 | */ |
||
333 | public function appendWhereValues($val): State |
||
348 | |||
349 | /** |
||
350 | * @return int |
||
351 | */ |
||
352 | public function getLimit(): ?int |
||
356 | |||
357 | /** |
||
358 | * @param int $limit |
||
359 | * @return State |
||
360 | */ |
||
361 | public function setLimit(int $limit): State |
||
366 | |||
367 | /** |
||
368 | * @return string|false |
||
369 | */ |
||
370 | public function getOffset() |
||
374 | |||
375 | /** |
||
376 | * @param string|false $offset |
||
377 | * @return State |
||
378 | */ |
||
379 | public function setOffset($offset): State |
||
384 | |||
385 | /** |
||
386 | * @return array |
||
387 | */ |
||
388 | public function getQueryMap(): array |
||
392 | |||
393 | /** |
||
394 | * Add an additional set of mapping pairs to a internal map |
||
395 | * |
||
396 | * @param string $conjunction |
||
397 | * @param string $string |
||
398 | * @param string $type |
||
399 | * @return State |
||
400 | */ |
||
401 | public function appendMap(string $conjunction = '', string $string = '', string $type = ''): self |
||
410 | |||
411 | /** |
||
412 | * @return array |
||
413 | */ |
||
414 | public function getHavingMap(): array |
||
418 | |||
419 | /** |
||
420 | * @param array $item |
||
421 | * @return State |
||
422 | */ |
||
423 | public function appendHavingMap(array $item): State |
||
428 | } |
||
429 |