Bug #69344 [NEW]: PDO PgSQL Incorrect binding numeric array with gaps
| From: | sergey dot nevmerzhitsky at gmail dot com | Date: | Wed, 01 Apr 2015 10:33:31 +0000 |
| Subject: | Bug #69344 [NEW]: PDO PgSQL Incorrect binding numeric array with gaps | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-191762@lists.php.net to get a copy of this message | ||
From: sergey dot nevmerzhitsky at gmail dot com
Operating system: Ubuntu 14.04.2 3.13.0-48
PHP version: 5.4.39
Package: PDO PgSQL
Bug Type: Bug
Bug description:PDO PgSQL Incorrect binding numeric array with gaps
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 bug report at https://bugs.php.net/bug.php?id=69344&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69344&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69344&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69344&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=69344&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=69344&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=69344&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=69344&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=69344&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=69344&r=support
Expected behavior: https://bugs.php.net/fix.php?id=69344&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=69344&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=69344&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=69344&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69344&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=69344&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=69344&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=69344&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69344&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=69344&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=69344&r=mysqlcfg