Bug #65287 [Opn->Csd]: PDOStatement::fetchAll wrong result
Edit report at https://bugs.php.net/bug.php?id=65287&edit=1
ID: 65287
Updated by: nikic@php.net
Reported by: ai at artem dot cc
Summary: PDOStatement::fetchAll wrong result
-Status: Open
+Status: Closed
Type: Bug
Package: PDO MySQL
Operating System: Centos
PHP Version: 5.6.16
-Assigned To:
+Assigned To: nikic
Block user comment: N
Private report: N
New Comment:
Per mbeccati's comment, this works fine in PHP 7, and PHP 5 is long since out of support. FWIW
I also just tested this, and it still works fine.
Previous Comments:
------------------------------------------------------------------------
[2017-04-24 20:15:12] adambaratz@php.net
Moving back to the PDO MySQL package based on Matteo's feedback.
------------------------------------------------------------------------
[2015-11-27 07:50:44] mbeccati@php.net
I've been able to replicate the issue on PHP 5.6, only when PDO_mysql is using mysqlnd. For
completeness, I've also tried PDO_pgsql, which is working just fine.
Even if the test table has two different int records (4 and 5), I get:
array(1) {
[""]=>
int(5)
}
The PHP-7.0 or master branches do not seem to be affected.
------------------------------------------------------------------------
[2014-02-25 14:30:58] ai at artem dot cc
Hi.
The problem appears in fetchAll method with PDO::FETCH_COLUMN | PDO::FETCH_UNIQUE, 0 as arguments.
Try fetch results from any table with fetchAll(PDO::FETCH_COLUMN | PDO::FETCH_UNIQUE, 0))
------------------------------------------------------------------------
[2014-02-25 13:15:34] uw@php.net
nixnutz@linux-dstv:~/src/php-src> grep -i -R stringi ext/pdo_*/*.c
nixnutz@linux-dstv:~/src/php-src> grep -i -R fetch_unique ext/pdo_*/*.c
AFAIK all this conversion stuff is core not driver stuff.
------------------------------------------------------------------------
[2014-02-25 13:09:37] uw@php.net
How would one support something for which there is not even any documentation... Apart from that it
just works fine for me...
$db = new PDO( "mysql:host=127.0.0.1;port=3311;dbname=test", "root",
"",
array( PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_EMULATE_PREPARES => false,
PDO::ATTR_STRINGIFY_FETCHES => true,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC ) );
$stmt = $db->query("SELECT 1, 1.23");
var_dump($stmt->fetchAll());
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);
$stmt = $db->query("SELECT 1, 1.23");
var_dump($stmt->fetchAll());
array(1) {
[0]=>
array(2) {
[1]=>
string(1) "1"
["1.23"]=>
string(4) "1.23"
}
}
array(1) {
[0]=>
array(2) {
[1]=>
int(1)
["1.23"]=>
string(4) "1.23"
}
}
Please, provide a proper case that can be reproduced. Fetching results from an unknown table
'test' cannot be reproduced and verified.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=65287
--
Edit this bug report at https://bugs.php.net/bug.php?id=65287&edit=1
Thread (7 messages)