ID: 47009 User updated by: andrew at ajohnstone dot com Reported By: andrew at ajohnstone dot com -Status: Feedback +Status: Open Bug Type: PDO related Operating System: fedora PHP Version: 5.2.8 New Comment:
Thanks for the quick response, I should have stated this was using MySQL PDO driver. Previous Comments: ------------------------------------------------------------------------ [2009-01-06 11:13:19] [email protected] I'm quite sure this is a problem with PS emulation, I have no test system at hand ... Not sue how to handle it in our parser:The SQL standard wants, afaik, a space behind the --, MySQL fr instance doesn't need it.Additionally the same problem should exist with /* */ comments, which are implemented in different way, too (MySQL need no */) Following the standard might still break stuff, not following the standard might break other case, making it driver dependent will give a mess... ------------------------------------------------------------------------ [2009-01-05 22:44:03] [email protected] Which SGBD are you using? ------------------------------------------------------------------------ [2009-01-05 22:36:31] [email protected] I can't reproduce it using sqlite. <?php $x = new pdo('sqlite::memory'); $x->query('create table if not exists foo (x int)'); $x->query('insert into foo values (1)'); $x->query('insert into foo values (2)'); $y = $x->prepare('select x from foo where -- x = ? x = ?'); var_dump($y->execute(array(2))); var_dump($y->fetch()); var_dump($y->errorInfo()); bool(true) array(2) { ["x"]=> string(1) "2" [0]=> string(1) "2" } array(1) { [0]=> string(5) "00000" } ------------------------------------------------------------------------ [2009-01-05 15:34:08] andrew at ajohnstone dot com Description: ------------ databaseException: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens Can't handle commented out lines with bound params Reproduce code: --------------- SELECT * FROM mapping_outlets mo JOIN media_outlets USING(mapping_outlets_id) WHERE -- mo.mapping_outlets_id = ? mo.media_outlets_id = ? GROUP BY ml.name ORDER BY NULL LIMIT 500 Expected result: ---------------- Ignore the commented outline. Actual result: -------------- databaseException: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=47009&edit=1
