php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79106 PDO may fetch wrong column indexes with PDO::FETCH_BOTH
Submitted: 2020-01-12 18:13 UTC Modified: 2020-01-13 17:52 UTC
From: cmb@php.net Assigned: cmb (profile)
Status: Closed Package: PDO Core
PHP Version: 7.3Git-2020-01-12 (Git) OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: cmb@php.net
New email:
PHP Version: OS:

 

 [2020-01-12 18:13 UTC] cmb@php.net
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"
  }
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-01-13 17:50 UTC] cmb@php.net
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=30ce242435393cfe629feffcba6e1f086af7205c
Log: Fix #79106: PDO may fetch wrong column indexes with PDO::FETCH_BOTH
 [2020-01-13 17:50 UTC] cmb@php.net
-Status: Open +Status: Closed
 [2020-01-13 17:52 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri May 29 05:01:25 2020 UTC