Bug #79106 [Opn->Csd]: PDO may fetch wrong column indexes with PDO::FETCH_BOTH

From: Date: Mon, 13 Jan 2020 17:50:13 +0000
Subject: Bug #79106 [Opn->Csd]: PDO may fetch wrong column indexes with PDO::FETCH_BOTH
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-224884@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79106&edit=1

 ID:                 79106
 Updated by:         cmb@php.net
 Reported by:        cmb@php.net
 Summary:            PDO may fetch wrong column indexes with
                     PDO::FETCH_BOTH
-Status:             Open
+Status:             Closed
 Type:               Bug
 Package:            PDO Core
 Operating System:   *
 PHP Version:        7.3Git-2020-01-12 (Git)
 Block user comment: N
 Private report:     N

 New Comment:

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


Previous Comments:
------------------------------------------------------------------------
[2020-01-12 18:17:07] cmb@php.net

Related To: Bug #79084

------------------------------------------------------------------------
[2020-01-12 18:13:36] 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"
  }
}



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=79106&edit=1


Thread (2 messages)

« previous php.bugs (#224884) next »