ID: 47977 Updated by: j...@php.net Reported By: fhgvbrdyftgjhgtfr at gazeta dot pl -Status: Open +Status: Feedback Bug Type: PDO related Operating System: Unix PHP Version: 5.2.9 New Comment:
Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with <?php and ends with ?>, is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. Previous Comments: ------------------------------------------------------------------------ [2009-04-16 00:22:47] fhgvbrdyftgjhgtfr at gazeta dot pl 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 this bug report at http://bugs.php.net/?id=47977&edit=1