1 | <?php |
||
16 | class QueryGrammar extends Grammar |
||
17 | { |
||
18 | /** |
||
19 | * The components that make up a select clause. |
||
20 | * |
||
21 | * @var array |
||
22 | */ |
||
23 | protected $selectComponents = [ |
||
24 | 'aggregate', |
||
25 | 'columns', |
||
26 | 'from', |
||
27 | 'joins', |
||
28 | 'wheres', |
||
29 | 'groups', |
||
30 | 'havings', |
||
31 | 'orders', |
||
32 | 'limit', |
||
33 | 'offset', |
||
34 | 'lock', |
||
35 | ]; |
||
36 | |||
37 | /** |
||
38 | * Compile a select query into SQL. |
||
39 | * |
||
40 | * @param \Childish\query\Builder $query |
||
41 | * @return string |
||
42 | */ |
||
43 | public function compileSelect(Builder $query) |
||
53 | |||
54 | /** |
||
55 | * Compile the random statement into SQL. |
||
56 | * |
||
57 | * @param string $seed |
||
58 | * @return string |
||
59 | */ |
||
60 | public function compileRandom($seed) |
||
64 | |||
65 | /** |
||
66 | * Compile the lock into SQL. |
||
67 | * |
||
68 | * @param \Childish\query\Builder $query |
||
69 | * @param bool|string $value |
||
70 | * @return string |
||
71 | */ |
||
72 | protected function compileLock(Builder $query, $value) |
||
80 | |||
81 | /** |
||
82 | * Compile an update statement into SQL. |
||
83 | * |
||
84 | * @param \Childish\query\Builder $query |
||
85 | * @param array $values |
||
86 | * @return string |
||
87 | */ |
||
88 | public function compileUpdate(Builder $query, $values) |
||
129 | |||
130 | /** |
||
131 | * Compile all of the columns for an update statement. |
||
132 | * |
||
133 | * @param array $values |
||
134 | * @return string |
||
135 | */ |
||
136 | protected function compileUpdateColumns($values) |
||
146 | |||
147 | /** |
||
148 | * Prepares a JSON column being updated using the JSON_SET function. |
||
149 | * |
||
150 | * @param string $key |
||
151 | * @param \Illuminate\Database\Query\JsonExpression $value |
||
152 | * @return string |
||
153 | */ |
||
154 | protected function compileJsonUpdateColumn($key, JsonExpression $value) |
||
164 | |||
165 | /** |
||
166 | * Prepare the bindings for an update statement. |
||
167 | * |
||
168 | * Booleans, integers, and doubles are inserted into JSON updates as raw values. |
||
169 | * |
||
170 | * @param array $bindings |
||
171 | * @param array $values |
||
172 | * @return array |
||
173 | */ |
||
174 | public function prepareBindingsForUpdate(array $bindings, array $values) |
||
183 | |||
184 | /** |
||
185 | * Compile a delete statement into SQL. |
||
186 | * |
||
187 | * @param \Childish\query\Builder $query |
||
188 | * @return string |
||
189 | */ |
||
190 | public function compileDelete(Builder $query) |
||
200 | |||
201 | /** |
||
202 | * Compile a delete query that does not use joins. |
||
203 | * |
||
204 | * @param \Childish\query\Builder $query |
||
205 | * @param string $table |
||
206 | * @param array $where |
||
207 | * @return string |
||
208 | */ |
||
209 | protected function compileDeleteWithoutJoins($query, $table, $where) |
||
226 | |||
227 | /** |
||
228 | * Compile a delete query that uses joins. |
||
229 | * |
||
230 | * @param \Childish\query\Builder $query |
||
231 | * @param string $table |
||
232 | * @param array $where |
||
233 | * @return string |
||
234 | */ |
||
235 | protected function compileDeleteWithJoins($query, $table, $where) |
||
244 | |||
245 | /** |
||
246 | * Wrap a single string in keyword identifiers. |
||
247 | * |
||
248 | * @param string $value |
||
249 | * @return string |
||
250 | */ |
||
251 | protected function wrapValue($value) |
||
266 | |||
267 | /** |
||
268 | * Wrap the given JSON selector. |
||
269 | * |
||
270 | * @param string $value |
||
271 | * @return string |
||
272 | */ |
||
273 | protected function wrapJsonSelector($value) |
||
283 | |||
284 | /** |
||
285 | * Determine if the given string is a JSON selector. |
||
286 | * |
||
287 | * @param string $value |
||
288 | * @return bool |
||
289 | */ |
||
290 | protected function isJsonSelector($value) |
||
294 | } |
||
295 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.