Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2870

Doctrine error when using SUM(a.id=1) as `ìdentifier`: Expected Doctrine\ORM\Query\Lexer::T_CLOSE_PARENTHESIS, got '='

    Details

    • Type: Bug Bug
    • Status: Awaiting Feedback
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: DQL
    • Security Level: All
    • Labels:
    • Environment:
      Symfony2 bundle

      Description

      Doctrine error when using SUM(a.id=1) as `ìdentifier`: Expected Doctrine\ORM\Query\Lexer::T_CLOSE_PARENTHESIS, got '='

      I am trying to execute a query in doctrine that contains something like this

      SUM(a.id = 1) as `1`
      for some reasons it always gives me the following error:

      [Syntax Error] line 0, col 15: Error: Expected Doctrine\ORM\Query\Lexer::T_CLOSE_PARENTHESIS, got '='
      This is the code i am using

      $result = $em->getRepository('MyBundle:PlayerAction')
      ->createQueryBuilder('pa')
      ->select(array(
      'SUM(a.id=1) as `1`,
      SUM(a.id=2) as `2`,
      SUM(a.id=3) as `3`,
      p.playerName,
      pa.timestamp'
      ))
      ->innerJoin('pa.action', 'a')
      ->innerJoin('pa.player', 'p')
      ->where('pa.timestamp > ?1')
      ->groupBy('p')
      ->setParameter(1, time() - $time)
      ->orderBy('p.playerName', 'ASC');

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Maxim Geerinck
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: