[DBAL-299] Multiple different interspersed named parameters Created: 06/Jul/12 Updated: 07/Jul/12 Resolved: 07/Jul/12
PHP 5.3.9-ZS5.6.0, Ubuntu 10.04.4 LTS on VirtualBox 4.1..18 r78361 on Mac OS X version 10.6.8
For this code
$sql = <<<SQL
$query = $em->createNativeQuery($sql, $rsm);
Generates the SQL in DBAL\Connection\executeQuery
SELECT 1 as id
The problem appears to be in DBAL\SQLParserUtils\expandListParameters.
When replacing the named parameters with ?'s an offset is kept to keep track of where to insert the next parameter. This is done per named parameter (all of :foo is replaced then all :bar, etc). This will calculate the incorrect offset if a named parameter(e.g. :bar) is in between instances of another named parameter (e.g. :foo) (i.e. :bar in the sql "(:foo = 2) AND (:bar =3) AND (:foo = 2)") since the offset will be for the TOTAL number of instances of the named parameter (e.g. -6) not the number of instances that occur before the needed replacement (e.g. -3).
This is where the SQL has "AN?bar = 3)" instead of "AND(3 = 3)" the offset is calculated at -6 instead of the proper -3
|Comment by Alexander [ 07/Jul/12 ]|