[DDC-1069] setParameter[s]() examples on DQL page uses ":" even though that is not supported Created: 13/Mar/11  Updated: 18/Nov/11  Resolved: 29/Mar/11

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.0.2
Fix Version/s: 2.0.4
Security Level: All

Type: Documentation Priority: Minor
Reporter: André R. Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None



Among others:
$query = $em->createQuery('SELECT u from ForumUser u WHERE (u.username = :name OR u.username = :name2) AND u.id = :id');
':name' => 'Bob',
':name2' => 'Alice',
':id' => 321,

Despite this does not work and doc says "When referencing the parameters in Query#setParameter($param, $value) both named and positional parameters are used without their prefixies." on same page.
(side note: prefixies => prefixes)

Fresh on doctrine 2.0 you typically copy past examples to try out stuff, and when exception then says that ":id" is not a valid param on this query you end up not knowing what went wrong.

Comment by Michael Ridgway [ 21/Mar/11 ]

I posted a simple patch for this at https://github.com/doctrine/orm-documentation/pull/20

Comment by André R. [ 22/Mar/11 ]

Looks good!

Comment by Benjamin Eberlei [ 29/Mar/11 ]


Comment by Christian S. [ 18/Nov/11 ]

You can find the same error in the PHPDoc of the methods setParameter(...) and setParameters(..) in class Doctrine\ORM\QueryBuilder.

* <code>
*     $qb = $em->createQueryBuilder()
*         ->select('u')
*         ->from('User', 'u')
*         ->where('u.id = :user_id')
*         ->setParameter(':user_id', 1);
* </code>

It would be nice if this will be fixed, because it is confusing, if you look at the autocomplete notice of the IDEs.

Generated at Tue Dec 01 18:47:17 EST 2015 using JIRA 6.4.10#64025-sha1:5b8b74079161cd76a20ab66dda52747ee6701bd6.