DDC-1069: setParameter[s]() examples on DQL page uses ":" even though that is not supported #1336

Closed
opened 2026-01-22 13:10:54 +01:00 by admin · 5 comments
Owner

Originally created by @doctrinebot on GitHub (Mar 13, 2011).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user anderom:

http://www.doctrine-project.org/docs/orm/2.0/en/reference/dql-doctrine-query-language.html

Among others:
$query = $em->createQuery('SELECT u from ForumUser u WHERE (u.username = :name OR u.username = :name2) AND u.id = :id');
$query->setParameters(array(
':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.

Originally created by @doctrinebot on GitHub (Mar 13, 2011). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user anderom: http://www.doctrine-project.org/docs/orm/2.0/en/reference/dql-doctrine-query-language.html Among others: $query = $em->createQuery('SELECT u from ForumUser u WHERE (u.username = :name OR u.username = :name2) AND u.id = :id'); $query->setParameters(array( ':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.
admin closed this issue 2026-01-22 13:10:55 +01:00
Author
Owner

@doctrinebot commented on GitHub (Mar 21, 2011):

Comment created by mridgway:

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

@doctrinebot commented on GitHub (Mar 21, 2011): Comment created by mridgway: I posted a simple patch for this at https://github.com/doctrine/orm-documentation/pull/20
Author
Owner

@doctrinebot commented on GitHub (Mar 22, 2011):

Comment created by anderom:

Looks good!

@doctrinebot commented on GitHub (Mar 22, 2011): Comment created by anderom: Looks good!
Author
Owner

@doctrinebot commented on GitHub (Mar 29, 2011):

Comment created by @beberlei:

Resolved

@doctrinebot commented on GitHub (Mar 29, 2011): Comment created by @beberlei: Resolved
Author
Owner

@doctrinebot commented on GitHub (Mar 29, 2011):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Mar 29, 2011): Issue was closed with resolution "Fixed"
Author
Owner

@doctrinebot commented on GitHub (Nov 18, 2011):

Comment created by naitsirch:

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.

@doctrinebot commented on GitHub (Nov 18, 2011): Comment created by naitsirch: 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.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#1336