Bug #79106 [NEW]: PDO may fetch wrong column indexes with PDO::FETCH_BOTH
| From: | cmb@php.net | Date: | Sun, 12 Jan 2020 18:13:36 +0000 |
| Subject: | Bug #79106 [NEW]: PDO may fetch wrong column indexes with PDO::FETCH_BOTH | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-224867@lists.php.net to get a copy of this message | ||
From: cmb
Operating system: *
PHP version: 7.3Git-2020-01-12 (Git)
Package: PDO Core
Bug Type: Bug
Bug description:PDO may fetch wrong column indexes with PDO::FETCH_BOTH
Description:
------------
I've noticed that PDO exhibits the same erroneous behavior
that has been reported as bug #79084 regarding MySQLi, namely
that PDO::FETCH_BOTH may mess up numeric indexes, if there are
numeric column names.
While this has been reported as bug #44190 long ago, and that
ticket has been closed as not a bug, I think we should reconsider.
Test script:
---------------
<?php
$pdo = new PDO('sqlite::memory:');
$stmt = $pdo->query("SELECT 0 as
2007, 0 as 2008, 0 as
2020");
var_dump($stmt->fetchAll());
?>
Expected result:
----------------
array(1) {
[0]=>
array(6) {
[0]=>
string(1) "0"
[2007]=>
string(1) "0"
[1]=>
string(1) "0"
[2008]=>
string(1) "0"
[2]=>
string(1) "0"
[2020]=>
string(1) "0"
}
}
Actual result:
--------------
array(1) {
[0]=>
array(5) {
[2007]=>
string(1) "0"
[2008]=>
string(1) "0"
[2009]=>
string(1) "0"
[2020]=>
string(1) "0"
[2021]=>
string(1) "0"
}
}
--
Edit bug report at https://bugs.php.net/bug.php?id=79106&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=79106&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=79106&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=79106&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=79106&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=79106&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=79106&r=support
Expected behavior: https://bugs.php.net/fix.php?id=79106&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=79106&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=79106&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=79106&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79106&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=79106&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=79106&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=79106&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=79106&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=79106&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=79106&r=mysqlcfg