@@ -116,7 +116,7 @@ protected function getDoctrineDriver()
116
116
}
117
117
118
118
/**
119
- * Compile for select.
119
+ * Compile the bindings for select.
120
120
*
121
121
* @param \Illuminate\Database\Query\Builder $builder
122
122
* @param array $bindings
@@ -148,15 +148,13 @@ private function compileForSelect(Builder $builder, $bindings) {
148
148
$ tables = $ alias ['table ' ];
149
149
}
150
150
151
+ // TODO: cache this query
151
152
$ queryString = $ this ->queryStringForSelect ($ tables );
152
-
153
153
$ queryRes = $ this ->getPdo ()->query ($ queryString );
154
-
155
154
$ types [$ tables ] = $ queryRes ->fetchAll (PDO ::FETCH_NAMED );
156
155
157
156
foreach ($ types [$ tables ] as &$ row ) {
158
157
$ tipos [strtolower ($ row ['name ' ])] = $ row ['type ' ];
159
-
160
158
$ tipos [strtolower ($ tables . '. ' . $ row ['name ' ])] = $ row ['type ' ];
161
159
162
160
if (!empty ($ alias ['alias ' ])) {
@@ -170,7 +168,7 @@ private function compileForSelect(Builder $builder, $bindings) {
170
168
171
169
foreach ($ builder ->wheres as $ w ) {
172
170
switch ($ w ['type ' ]) {
173
- case ' Nested ' :
171
+ case " Nested " :
174
172
$ wheres += $ w ['query ' ]->wheres ;
175
173
break ;
176
174
default :
@@ -180,11 +178,13 @@ private function compileForSelect(Builder $builder, $bindings) {
180
178
}
181
179
182
180
$ i = 0 ;
183
-
184
181
$ wheresCount = count ($ wheres );
185
182
186
183
for ($ ind = 0 ; $ ind < $ wheresCount ; $ ind ++) {
187
- if (
184
+ if ($ wheres [$ ind ]['type ' ] == 'raw ' ) {
185
+ $ newBinds [] = $ bindings [$ i ];
186
+ $ i ++;
187
+ } else if (
188
188
isset ($ wheres [$ ind ]['value ' ]) &&
189
189
isset ($ tipos [strtolower ($ wheres [$ ind ]['column ' ])])
190
190
) {
@@ -205,7 +205,6 @@ private function compileForSelect(Builder $builder, $bindings) {
205
205
} else {
206
206
$ newBinds [$ i ] = (string ) $ bindings [$ i ];
207
207
}
208
-
209
208
$ i ++;
210
209
}
211
210
}
@@ -214,14 +213,22 @@ private function compileForSelect(Builder $builder, $bindings) {
214
213
$ newFormat [$ tables ] = [];
215
214
}
216
215
217
- $ wheres = (array ) $ builder ->wheres ;
218
216
217
+ /**
218
+ * Is this block duplicated? Need more tests will keep it
219
+ * commented to remember that a possible error could be related to
220
+ * this
221
+ */
222
+ /**
223
+ $wheres = (array) $builder->wheres;
219
224
$i = 0;
220
-
221
225
$wheresCount = count($wheres);
222
226
223
227
for ($ind = 0; $ind < $wheresCount; $ind++) {
224
- if (isset ($ wheres [$ ind ]['value ' ])) {
228
+ if ($wheres[$ind]['type'] == 'raw') {
229
+ $newBinds[] = $bindings[$i];
230
+ $i++;
231
+ } else if (isset($wheres[$ind]['value'])) {
225
232
if (is_object($wheres[$ind]['value']) === false) {
226
233
if (
227
234
in_array(
@@ -239,11 +246,11 @@ private function compileForSelect(Builder $builder, $bindings) {
239
246
} else {
240
247
$newBinds[$i] = (string) $bindings[$i];
241
248
}
242
-
243
249
$i++;
244
250
}
245
251
}
246
252
}
253
+ */
247
254
248
255
return $ newBinds ;
249
256
}
0 commit comments