|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2021-07-24 12:30 UTC] tropicano at ukr dot net
Description:
------------
Unexpected phantom rowset and no error when PDO::MYSQL_ATTR_USE_BUFFERED_QUERY = FALSE.
When PDO::MYSQL_ATTR_USE_BUFFERED_QUERY = TRUE then result expected.
Test script:
---------------
$db = new PDO("mysql:host=$db_host;dbname=$db_name", $db_user, $db_pass, [PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => FALSE]);
$qr = $db->query('SELECT IF(1, (SELECT 1 UNION ALL SELECT 2), 0)');
print_r($db->errorInfo()); // here is no error
if ($qr) {
print_r($qr->errorInfo()); // here is no error too
$qr->nextRowset(); // return false;
print_r($qr->errorInfo()); // here is no error again
}
Expected result:
----------------
Array
(
[0] => 21000
[1] => 1242
[2] => Subquery returns more than 1 row
)
Actual result:
--------------
Array
(
[0] => 00000
[1] =>
[2] =>
)
Array
(
[0] => 00000
[1] =>
[2] =>
)
Array
(
[0] => 00000
[1] =>
[2] =>
)
PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 19:00:02 2025 UTC |
Thanks for reporting this issue. This has already been fixed in PHP 8.0.1 but the fix was not backported to PHP 7. It might be possible to backport it... FYI, your expected result doesn't match what really should happen. The proper output with SILENT mode enabled should be: Array ( [0] => 00000 [1] => [2] => ) Array ( [0] => 00000 [1] => [2] => ) Array ( [0] => 21000 [1] => 1242 [2] => Subquery returns more than 1 row )Ok, then another query like this: $qr = $db->query('SELECT SELECT'); why returns FALSE and error info ? What different? Subject query and this second query both with errors. But subject query return PDOStatement and second query return FALSE. I think in this case both PDO::query() must return same result - FALSE or PDOStatement with errors.