From: fhgvbrdyftgjhgtfr at gazeta dot pl Operating system: Unix PHP version: 5.2.9 PHP Bug Type: PDO related Bug description: bindParam, current(), next()
Description: ------------ bindParam doesn't work with vars returned by current(), next() Reproduce code: --------------- <?php $array = array_diff($array2, array_keys($array3)); reset($array); $size = count($array); $in = '?'; for($i = 1; $i < $size; ++$i) $in .= ', ?'; $stmt = $db->prepare('SELECT `name` FROM `table` WHERE `language` = ? AND `code` IN('.$in.')'); $stmt->bindValue(1, 'en', PDO::PARAM_STR, 2); $i = 1; $element = current($array); do { $stmt->bindParam(++$i, $element, PDO::PARAM_STR, 2); } while(($element = next($array)) !== false); Expected result: ---------------- SELECT `name` FROM `table` WHERE `language` = 'en' AND `code` IN('us', 'gb', 'nz') Actual result: -------------- SELECT `name` FROM `table` WHERE `language` = 'en' AND `code` IN('0', '0', '0') When i change $stmt->bindParam(++$i, $element, PDO::PARAM_STR, 2); to $stmt->bindValue(++$i, $element, PDO::PARAM_STR, 2); i get: SELECT `name` FROM `table` WHERE `language` = 'en' AND `code` IN('us', 'gb', 'nz') -- Edit bug report at http://bugs.php.net/?id=47977&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=47977&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=47977&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=47977&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=47977&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=47977&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=47977&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=47977&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=47977&r=needscript Try newer version: http://bugs.php.net/fix.php?id=47977&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=47977&r=support Expected behavior: http://bugs.php.net/fix.php?id=47977&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=47977&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=47977&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=47977&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47977&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=47977&r=dst IIS Stability: http://bugs.php.net/fix.php?id=47977&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=47977&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=47977&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=47977&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=47977&r=mysqlcfg