Bug #69344 [Ver->Csd]: PDO PgSQL Incorrect binding numeric array with gaps

From: Date: Fri, 12 Jun 2015 00:09:24 +0000
Subject: Bug #69344 [Ver->Csd]: PDO PgSQL Incorrect binding numeric array with gaps
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-193348@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: Verified +Status: Closed Type: Bug Package: PDO PgSQL Operating System: Ubuntu 14.04.2 3.13.0-48 PHP Version: 5.4.39 Assigned To: mbeccati Block user comment: N Private report: N New Comment: Automatic comment on behalf of mbeccati Revision: http://git.php.net/?p=php-src.git;a=commit;h=b60efdce9fe7e168ba37070a4307269483a66ea4 Log: Fix bug #69344 (PDO PgSQL Incorrect binding numeric array with gaps) Previous Comments: ------------------------------------------------------------------------ [2015-06-11 21:53:31] mbeccati@php.net This might require some discussion as fixing it would be a behaviour change. ------------------------------------------------------------------------ [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

« previous php.bugs (#193348) next »