Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-1455

Selecting association id (FK) without join

    Details

    • Type: New Feature New Feature
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Invalid
    • Affects Version/s: None
    • Fix Version/s: 2.2
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None

      Description

      It might be a missing feature or I might be doing something wrong. I need to select an association (FK) without the need of a join.

      I'm trying something like this:

      select i.client.id , count(i) as total 
      from \Invoice i 
      GROUP BY i.client
      

      But I get this error:
      Error: Expected Doctrine\ORM\Query\Lexer::T_FROM, got '.'

        Activity

        Hide
        Benjamin Eberlei added a comment -

        Try

        SELECT i.client, count(i) AS total
        
        Show
        Benjamin Eberlei added a comment - Try SELECT i.client, count(i) AS total
        Hide
        Guilherme Blanco added a comment -

        This is already supported in 2.2-DEV through IDENTITY() DQL function.

        SELECT IDENTITY(i.client), count(i) as total 
          FROM \Invoice i 
         GROUP BY i.client
        
        Show
        Guilherme Blanco added a comment - This is already supported in 2.2-DEV through IDENTITY() DQL function. SELECT IDENTITY(i.client), count(i) as total FROM \Invoice i GROUP BY i.client

          People

          • Assignee:
            Guilherme Blanco
            Reporter:
            Wladimir Coka
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: