Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Invalid
-
Affects Version/s: 2.0-BETA2
-
Fix Version/s: None
-
Component/s: DQL
-
Security Level: All
-
Labels:None
Description
The following won't work:
$qb->andWhere('(a.campaign IS NOT NULL AND (cmp.user IS NULL OR cmp.user = :currentUser) OR a.previewTarget IS NOT NULL AND pt.user = :currentUser)')
->setParameter('currentUser', $currentUser);
The following will, but seems needlessly complex:
$qb->andWhere('(a.campaign IS NOT NULL AND (cmp.user IS NULL OR cmp.user = :currentUserA) OR a.previewTarget IS NOT NULL AND pt.user = :currentUserB)')
->setParameter('currentUserA', $currentUser)
->setParameter('currentUserB', $currentUser);
I would expect a named parameter to behave like a constant. I should be able to define it once, and then use it multiple times.
Also, I would like to be able to set the same parameter multiple times, so if multiple pieces of code set :currentUser that isn't a problem, unless they're different (in which case I'd expect an error like ":currentUser bound to two different values").
The Doctrine behavios is expected and correct.
Each parameter is atomic and can only be used once.
There is not way to implement it other way (AFAIK), but if you come with a patch... who knows! =)
Regards,