Details
-
Type:
Improvement
-
Status:
Closed
-
Priority:
Major
-
Resolution: Won't Fix
-
Affects Version/s: 2.2
-
Fix Version/s: None
-
Component/s: ORM
-
Security Level: All
-
Labels:None
Description
$qb = $em->createQueryBuilder(); /* @var $qb Doctrine\ORM\QueryBuilder */
$roles = $qb->from('App_Model_Role', 'r')
->select('r')
->orderBy('IFNULL(r.rootId, r.id), r.lft')
->getQuery()
->getResult();
[Syntax Error] line 0, col 46: Error: Expected end of string, got '('
I have the same error while using FIELD mysql function.
I added beberlei/DoctrineExtensions to my Symfony2 project to enable the FIELD function, but I'm able to use it in SELECT clause only. The problem is that in that case Doctrine returns bad result for me. Here is the example:
$queryBuilder ->addSelect('FIELD(u.id, 1, 2) as relevanceField') ->orderBy('relevanceField') ;The result of
foreach($queryBuilder->getQuery()->getResult() as $r) { ... }is:
Without that addSelect() function call I have correct result:
So I think orderByItem() function in Parser.php class should be extended so that MySQL function could be used there.