We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 043ea84 commit c5ca758Copy full SHA for c5ca758
1 file changed
wp-includes/sqlite-ast/class-wp-pdo-synthetic-statement.php
@@ -239,6 +239,22 @@ public function fetch(
239
* Without it, these parameters have no effect.
240
*/
241
242
+ /**
243
+ * With PHP < 8.1, the "PDO::ATTR_STRINGIFY_FETCHES" value of "false"
244
+ * is not working correctly with the PDO SQLite driver. In such case,
245
+ * we need to manually convert the row values to the correct types.
246
+ */
247
+ if ( PHP_VERSION_ID < 80100 && ! $this->getAttribute( PDO::ATTR_STRINGIFY_FETCHES ) ) {
248
+ foreach ( $row as $i => $value ) {
249
+ $type = $this->columns[ $i ]['native_type'];
250
+ if ( 'integer' === $type ) {
251
+ $row[ $i ] = (int) $value;
252
+ } elseif ( 'float' === $type ) {
253
+ $row[ $i ] = (float) $value;
254
+ }
255
256
257
+
258
switch ( $mode ) {
259
case PDO::FETCH_BOTH:
260
$values = array();
0 commit comments