#47009 [Fbk]: PDO can't handle commented out lines with bound params

From: Date: Tue, 06 Jan 2009 11:13:19 +0000
Subject: #47009 [Fbk]: PDO can't handle commented out lines with bound params
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-132584@lists.php.net to get a copy of this message
 ID:               47009
 Updated by:       johannes@php.net
 Reported By:      andrew at ajohnstone dot com
 Status:           Feedback
 Bug Type:         PDO related
 Operating System: fedora
 PHP Version:      5.2.8
 New Comment:

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...


Previous Comments:
------------------------------------------------------------------------

[2009-01-05 22:44:03] felipe@php.net

Which SGBD are you using?

------------------------------------------------------------------------

[2009-01-05 22:36:31] felipe@php.net

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



Thread (6 messages)

« previous php.bugs (#132584) next »