@@ -137,18 +137,29 @@ public function execute()
137
137
$ fake_result = $ this ->result ;
138
138
$ real_result = $ this ->realStatement ->fetchAll (\PDO ::FETCH_ASSOC );
139
139
140
- if ($ this ->conn ->stringifyResult && $ fake_result ) {
141
- $ fake_result = array_map (
142
- function ($ row ) {
143
- return self ::stringify ($ row );
144
- },
145
- $ fake_result
146
- );
140
+ if ($ fake_result ) {
141
+ if ($ this ->conn ->stringifyResult ) {
142
+ $ fake_result = array_map (
143
+ function ($ row ) {
144
+ return self ::stringify ($ row );
145
+ },
146
+ $ fake_result
147
+ );
148
+ }
149
+
150
+ if ($ this ->conn ->lowercaseResultKeys ) {
151
+ $ fake_result = array_map (
152
+ function ($ row ) {
153
+ return self ::lowercaseKeys ($ row );
154
+ },
155
+ $ fake_result
156
+ );
157
+ }
147
158
}
148
159
149
160
if ($ real_result !== $ fake_result ) {
150
- // var_dump($real_result, $fake_result);
151
- // throw new \UnexpectedValueException('different');
161
+ var_dump ($ real_result , $ fake_result );
162
+ throw new \UnexpectedValueException ('different ' );
152
163
}
153
164
}
154
165
@@ -213,6 +224,10 @@ public function fetch(
213
224
$ row = self ::stringify ($ row );
214
225
}
215
226
227
+ if ($ this ->conn ->lowercaseResultKeys ) {
228
+ $ row = self ::lowercaseKeys ($ row );
229
+ }
230
+
216
231
if ($ fetch_style === \PDO ::FETCH_ASSOC ) {
217
232
$ this ->resultCursor ++;
218
233
@@ -249,14 +264,20 @@ public function fetchAll(int $fetch_style = -123, $fetch_argument = null, array
249
264
}
250
265
251
266
if ($ fetch_style === \PDO ::FETCH_ASSOC ) {
252
- if ($ this ->conn ->stringifyResult ) {
253
- return array_map (
254
- function ($ row ) {
255
- return self ::stringify ($ row );
256
- },
257
- $ this ->result ?: []
258
- );
259
- }
267
+ return array_map (
268
+ function ($ row ) {
269
+ if ($ this ->conn ->stringifyResult ) {
270
+ $ row = self ::stringify ($ row );
271
+ }
272
+
273
+ if ($ this ->conn ->lowercaseResultKeys ) {
274
+ $ row = self ::lowercaseKeys ($ row );
275
+ }
276
+
277
+ return self ::stringify ($ row );
278
+ },
279
+ $ this ->result ?: []
280
+ );
260
281
261
282
return $ this ->result ?: [];
262
283
}
@@ -281,6 +302,10 @@ function ($row) {
281
302
$ row = self ::stringify ($ row );
282
303
}
283
304
305
+ if ($ this ->conn ->lowercaseResultKeys ) {
306
+ $ row = self ::lowercaseKeys ($ row );
307
+ }
308
+
284
309
return array_merge ($ row , \array_values ($ row ));
285
310
},
286
311
$ this ->result ?: []
@@ -314,6 +339,10 @@ function ($row) use ($fetch_argument, $ctor_args) {
314
339
$ row = self ::stringify ($ row );
315
340
}
316
341
342
+ if ($ this ->conn ->lowercaseResultKeys ) {
343
+ $ row = self ::lowercaseKeys ($ row );
344
+ }
345
+
317
346
return self ::convertRowToObject ($ row , $ fetch_argument , $ ctor_args );
318
347
},
319
348
$ this ->result
@@ -368,6 +397,17 @@ function ($value) {
368
397
);
369
398
}
370
399
400
+ private static function lowercaseKeys (array $ row )
401
+ {
402
+ $ lowercased_row = [];
403
+
404
+ foreach ($ row as $ col => $ value ) {
405
+ $ lowercased_row [\strtolower ($ col )] = $ value ;
406
+ }
407
+
408
+ return $ lowercased_row ;
409
+ }
410
+
371
411
/**
372
412
* @psalm-taint-sink callable $class
373
413
*
0 commit comments