Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-1335

QueryBuilder->form() does not allow the INDEX BY clause

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1
    • Fix Version/s: 2.1.3
    • Component/s: DQL
    • Security Level: All
    • Labels:
      None

      Description

      The QueryBuilder does not allow the INDEX BY clause in the form() function, so queris like 'SELECT u FROM User u INDEX BY u.id' are not possible just using the QueryBuilder. There is the option in the join() functions but when a join is not needed, you can only use DQL.

      If you find id appropiate i'll work on a patch for the issue.

        Activity

        Hide
        Sander Marechal added a comment - - edited

        I too would like to see this. I thought this issue was fixed with DDC-1145 but that only solves it for joins. It does not allow indexing on the result itself. I would like to see something like this:

        $builder->select('u')->from('User')->indexBy('u.id');
        $builder->getQuery()->getResult();
        

        Or it may be better to implement it on the query (since it affects hydration rather than the query itself):

        $builder->select('u')->from('User');
        $builder->getQuery()->setIndex('u.id')->getResult();
        
        Show
        Sander Marechal added a comment - - edited I too would like to see this. I thought this issue was fixed with DDC-1145 but that only solves it for joins. It does not allow indexing on the result itself. I would like to see something like this: $builder->select('u')->from('User')->indexBy('u.id'); $builder->getQuery()->getResult(); Or it may be better to implement it on the query (since it affects hydration rather than the query itself): $builder->select('u')->from('User'); $builder->getQuery()->setIndex('u.id')->getResult();
        Show
        Guilherme Blanco added a comment - Fixed in https://github.com/doctrine/doctrine2/commit/80284a273ded303c059b013808d1199d8546d359

          People

          • Assignee:
            Guilherme Blanco
            Reporter:
            Albert Casademont
          • Votes:
            3 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: