Bug #69344 [Opn->Ver]: PDO PgSQL Incorrect binding numeric array with gaps
| From: | mbeccati@php.net | Date: | Thu, 11 Jun 2015 21:53:31 +0000 |
| Subject: | Bug #69344 [Opn->Ver]: PDO PgSQL Incorrect binding numeric array with gaps | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-193344@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=69344&edit=1
ID: 69344
Updated by: mbeccati@php.net
Reported by: sergey dot nevmerzhitsky at gmail dot com
Summary: PDO PgSQL Incorrect binding numeric array with gaps
-Status: Open
+Status: Verified
Type: Bug
Package: PDO PgSQL
Operating System: Ubuntu 14.04.2 3.13.0-48
PHP Version: 5.4.39
-Assigned To:
+Assigned To: mbeccati
Block user comment: N
Private report: N
New Comment:
This might require some discussion as fixing it would be a behaviour change.
Previous Comments:
------------------------------------------------------------------------
[2015-04-01 10:33:30] sergey dot nevmerzhitsky at gmail dot com
Description:
------------
If pass a numeric array with gaps in keys as argument of PDOStatement::execute(), DB returns not all
matched rows.
Test script:
---------------
$needValues = [
'aaa',
'bbb',
'ccc',
'bbb', // Copy of key 1.
'ddd'
];
$needValues = array_unique($needValues); // Produce array with keys gap
// $needValues = array_values(array_unique($needValues)); // No keys gap => NO BUG
$sql = 'SELECT "value" FROM "values_table" WHERE "value" IN
(%s)';
$sql = sprintf($sql, implode(',', array_fill(0, count($needValues), '?')));
$stmt = $postgresDb->prepare($sql);
$stmt->execute($needValues);
var_dump($stmt->fetchAll());
Expected result:
----------------
"ddd"
"ccc"
"bbb"
"aaa"
Actual result:
--------------
"ccc"
"bbb"
"aaa"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=69344&edit=1