1 | <?php |
||
22 | abstract class AbstractQuery |
||
23 | { |
||
24 | /** |
||
25 | * |
||
26 | * Data to be bound to the query. |
||
27 | * |
||
28 | * @var array |
||
29 | * |
||
30 | */ |
||
31 | protected $bind_values = array(); |
||
32 | |||
33 | /** |
||
34 | * |
||
35 | * The list of WHERE conditions. |
||
36 | * |
||
37 | * @var array |
||
38 | * |
||
39 | */ |
||
40 | protected $where = array(); |
||
41 | |||
42 | /** |
||
43 | * |
||
44 | * ORDER BY these columns. |
||
45 | * |
||
46 | * @var array |
||
47 | * |
||
48 | */ |
||
49 | protected $order_by = array(); |
||
50 | |||
51 | /** |
||
52 | * |
||
53 | * The list of flags. |
||
54 | * |
||
55 | * @var array |
||
56 | * |
||
57 | */ |
||
58 | protected $flags = array(); |
||
59 | |||
60 | /** |
||
61 | * |
||
62 | * A helper for quoting identifier names. |
||
63 | * |
||
64 | * @var Quoter |
||
65 | * |
||
66 | */ |
||
67 | protected $quoter; |
||
68 | |||
69 | /** |
||
70 | * |
||
71 | * Constructor. |
||
72 | * |
||
73 | * @param Quoter $quoter A helper for quoting identifier names. |
||
74 | * |
||
75 | */ |
||
76 | 417 | public function __construct(QuoterInterface $quoter, $builder) |
|
81 | |||
82 | /** |
||
83 | * |
||
84 | * Returns this query object as an SQL statement string. |
||
85 | * |
||
86 | * @return string |
||
87 | * |
||
88 | */ |
||
89 | 243 | public function __toString() |
|
93 | |||
94 | /** |
||
95 | * |
||
96 | * Returns this query object as an SQL statement string. |
||
97 | * |
||
98 | * @return string |
||
99 | * |
||
100 | */ |
||
101 | 69 | public function getStatement() |
|
105 | |||
106 | /** |
||
107 | * |
||
108 | * Builds this query object into a string. |
||
109 | * |
||
110 | * @return string |
||
111 | * |
||
112 | */ |
||
113 | abstract protected function build(); |
||
114 | |||
115 | /** |
||
116 | * |
||
117 | * Returns the prefix to use when quoting identifier names. |
||
118 | * |
||
119 | * @return string |
||
120 | * |
||
121 | */ |
||
122 | 267 | public function getQuoteNamePrefix() |
|
126 | |||
127 | /** |
||
128 | * |
||
129 | * Returns the suffix to use when quoting identifier names. |
||
130 | * |
||
131 | * @return string |
||
132 | * |
||
133 | */ |
||
134 | 267 | public function getQuoteNameSuffix() |
|
138 | |||
139 | /** |
||
140 | * |
||
141 | * Binds multiple values to placeholders; merges with existing values. |
||
142 | * |
||
143 | * @param array $bind_values Values to bind to placeholders. |
||
144 | * |
||
145 | * @return $this |
||
146 | * |
||
147 | */ |
||
148 | 41 | public function bindValues(array $bind_values) |
|
149 | { |
||
150 | // array_merge() renumbers integer keys, which is bad for |
||
151 | // question-mark placeholders |
||
152 | 41 | foreach ($bind_values as $key => $val) { |
|
153 | 31 | $this->bindValue($key, $val); |
|
154 | } |
||
155 | 41 | return $this; |
|
156 | } |
||
157 | |||
158 | /** |
||
159 | * |
||
160 | * Binds a single value to the query. |
||
161 | * |
||
162 | * @param string $name The placeholder name or number. |
||
163 | * |
||
164 | * @param mixed $value The value to bind to the placeholder. |
||
165 | * |
||
166 | * @return $this |
||
167 | * |
||
168 | */ |
||
169 | 136 | public function bindValue($name, $value) |
|
174 | |||
175 | /** |
||
176 | * |
||
177 | * Gets the values to bind to placeholders. |
||
178 | * |
||
179 | * @return array |
||
180 | * |
||
181 | */ |
||
182 | 126 | public function getBindValues() |
|
186 | |||
187 | /** |
||
188 | * |
||
189 | * Reset all values bound to named placeholders. |
||
190 | * |
||
191 | * @return $this |
||
192 | * |
||
193 | */ |
||
194 | 15 | public function resetBindValues() |
|
199 | |||
200 | /** |
||
201 | * |
||
202 | * Sets or unsets specified flag. |
||
203 | * |
||
204 | * @param string $flag Flag to set or unset |
||
205 | * |
||
206 | * @param bool $enable Flag status - enabled or not (default true) |
||
207 | * |
||
208 | * @return null |
||
209 | * |
||
210 | */ |
||
211 | 43 | protected function setFlag($flag, $enable = true) |
|
212 | { |
||
213 | 43 | if ($enable) { |
|
214 | 43 | $this->flags[$flag] = true; |
|
215 | } else { |
||
216 | 5 | unset($this->flags[$flag]); |
|
217 | } |
||
218 | 43 | } |
|
219 | |||
220 | /** |
||
221 | * |
||
222 | * Returns true if the specified flag was enabled by setFlag(). |
||
223 | * |
||
224 | * @param string $flag Flag to check |
||
225 | * |
||
226 | * @return bool |
||
227 | * |
||
228 | */ |
||
229 | 10 | protected function hasFlag($flag) |
|
233 | |||
234 | /** |
||
235 | * |
||
236 | * Reset all query flags. |
||
237 | * |
||
238 | * @return $this |
||
239 | * |
||
240 | */ |
||
241 | 20 | public function resetFlags() |
|
246 | |||
247 | /** |
||
248 | * |
||
249 | * Adds conditions and binds values to a clause. |
||
250 | * |
||
251 | * @param string $clause The clause to work with, typically 'where' or |
||
252 | * 'having'. |
||
253 | * |
||
254 | * @param string $andor Add the condition using this operator, typically |
||
255 | * 'AND' or 'OR'. |
||
256 | * |
||
257 | * @param string $cond The WHERE condition. |
||
258 | * |
||
259 | * @param array $bind arguments to bind to placeholders |
||
260 | * |
||
261 | * @return null |
||
262 | * |
||
263 | */ |
||
264 | 80 | protected function addClauseCondWithBind($clause, $andor, $cond, $bind) |
|
282 | |||
283 | 10 | protected function addClauseCondClosure($clause, $andor, $closure) |
|
318 | |||
319 | /** |
||
320 | * |
||
321 | * Rebuilds a condition string, replacing sequential placeholders with |
||
322 | * named placeholders, and binding the sequential values to the named |
||
323 | * placeholders. |
||
324 | * |
||
325 | * @param string $cond The condition with sequential placeholders. |
||
326 | * |
||
327 | * @param array $bind_values The values to bind to the sequential |
||
328 | * placeholders under their named versions. |
||
329 | * |
||
330 | * @return string The rebuilt condition string. |
||
331 | * |
||
332 | */ |
||
333 | 130 | protected function rebuildCondAndBindValues($cond, array $bind_values) |
|
356 | |||
357 | /** |
||
358 | * |
||
359 | * Adds a column order to the query. |
||
360 | * |
||
361 | * @param array $spec The columns and direction to order by. |
||
362 | * |
||
363 | * @return $this |
||
364 | * |
||
365 | */ |
||
366 | 9 | protected function addOrderBy(array $spec) |
|
373 | } |
||
374 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..