1 | <?php |
||
22 | abstract class AbstractQueryBuilder extends \yii\base\Object implements QueryBuilderInterface |
||
23 | { |
||
24 | /** |
||
25 | * @var AbstractConnection |
||
26 | */ |
||
27 | public $db; |
||
28 | |||
29 | 2 | public function __construct($connection, $config = []) |
|
34 | |||
35 | /** |
||
36 | * Builds config array to create Command. |
||
37 | * @param Query $query |
||
38 | * @throws NotSupportedException |
||
39 | * @return array |
||
40 | */ |
||
41 | 2 | public function build(Query $query) |
|
45 | |||
46 | 3 | public function createRequest($query) |
|
50 | |||
51 | /** |
||
52 | * Prepares query before actual building. |
||
53 | * This function for you to redefine. |
||
54 | * It will be called before other build functions. |
||
55 | * @param Query $query |
||
56 | */ |
||
57 | 2 | public function prepare(Query $query) |
|
61 | |||
62 | /** |
||
63 | * This function is for you to provide your authentication. |
||
64 | * @param Query $query |
||
65 | */ |
||
66 | abstract public function buildAuth(Query $query); |
||
67 | |||
68 | abstract public function buildMethod(Query $query); |
||
69 | |||
70 | abstract public function buildUri(Query $query); |
||
71 | |||
72 | abstract public function buildHeaders(Query $query); |
||
73 | |||
74 | abstract public function buildProtocolVersion(Query $query); |
||
75 | |||
76 | abstract public function buildQueryParams(Query $query); |
||
77 | |||
78 | abstract public function buildFormParams(Query $query); |
||
79 | |||
80 | abstract public function buildBody(Query $query); |
||
81 | |||
82 | /** |
||
83 | * Creates insert request. |
||
84 | * @param string $table |
||
85 | * @param array $columns |
||
86 | * @param array $options |
||
87 | * @return AbstractRequest |
||
88 | */ |
||
89 | 1 | public function insert($table, $columns, array $options = []) |
|
93 | |||
94 | /** |
||
95 | * Creates update request. |
||
96 | * @param string $table |
||
97 | * @param array $columns |
||
98 | * @param array $options |
||
99 | * @return AbstractRequest |
||
100 | */ |
||
101 | public function update($table, $columns, $condition = [], array $options = []) |
||
107 | |||
108 | public function delete($table, $condition = [], array $options = []) |
||
114 | |||
115 | 1 | public function perform($action, $table, $body, $options = []) |
|
121 | |||
122 | 1 | public function createQuery($action, $table, array $options = []) |
|
128 | |||
129 | public function buildCondition($condition) |
||
166 | |||
167 | protected function buildHashCondition($condition) |
||
168 | { |
||
169 | $parts = []; |
||
170 | foreach ($condition as $attribute => $value) { |
||
171 | if (is_array($value)) { // IN condition |
||
172 | // $parts[] = [$attribute.'s' => join(',',$value)]; |
||
173 | $parts[$attribute . 's'] = implode(',', $value); |
||
174 | } else { |
||
175 | $parts[$attribute] = $value; |
||
176 | } |
||
177 | } |
||
178 | |||
179 | return $parts; |
||
180 | } |
||
181 | |||
182 | protected function buildLikeCondition($operator, $operands) |
||
186 | |||
187 | protected function buildIlikeCondition($operator, $operands) |
||
191 | |||
192 | protected function buildCompareCondition($operator, $operands) |
||
200 | |||
201 | protected function buildAndCondition($operator, $operands) |
||
202 | { |
||
203 | $parts = []; |
||
204 | foreach ($operands as $operand) { |
||
205 | if (is_array($operand)) { |
||
206 | $parts = ArrayHelper::merge($this->buildCondition($operand), $parts); |
||
207 | } |
||
208 | } |
||
209 | if (!empty($parts)) { |
||
210 | return $parts; |
||
211 | } else { |
||
212 | return []; |
||
213 | } |
||
214 | } |
||
215 | |||
216 | protected function buildBetweenCondition($operator, $operands) |
||
220 | |||
221 | protected function buildInCondition($operator, $operands, $not = false) |
||
222 | { |
||
223 | if (!isset($operands[0], $operands[1])) { |
||
224 | throw new InvalidParamException("Operator '$operator' requires two operands."); |
||
225 | } |
||
226 | |||
227 | list($column, $values) = $operands; |
||
228 | |||
229 | if (count($column) > 1) { |
||
230 | return $this->buildCompositeInCondition($operator, $column, $values); |
||
231 | } elseif (is_array($column)) { |
||
232 | $column = reset($column); |
||
233 | } |
||
234 | |||
235 | foreach ((array) $values as $i => $value) { |
||
236 | if (is_array($value)) { |
||
237 | $values[$i] = $value = isset($value[$column]) ? $value[$column] : null; |
||
238 | } |
||
239 | if ($value === null) { |
||
240 | unset($values[$i]); |
||
241 | } |
||
242 | } |
||
243 | |||
244 | if ($not) { |
||
245 | $key = $column . '_ni'; // not in |
||
246 | } else { |
||
247 | $key = $column . '_in'; |
||
248 | } |
||
249 | return [$key => $values]; |
||
250 | } |
||
251 | |||
252 | protected function buildNotInCondition($operator, $operands) |
||
256 | |||
257 | protected function buildEqCondition($operator, $operands) |
||
263 | |||
264 | protected function buildNotEqCondition($operator, $operands) |
||
270 | |||
271 | protected function buildCompositeInCondition($operator, $columns, $values) |
||
275 | } |
||
276 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: