Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Update lib/Doctrine/ORM/EntityRepository.php #571

Closed
wants to merge 1 commit into from

3 participants

Flo doctrinebot Benjamin Eberlei
Flo

Add "indexby" missing parameter that permit an "index by" easily.

Ex : 
#Acme\AcmeBundle\Repository
#Before
public function findAllIndexById(){
$qb = $this->_em->createQueryBuilder()
->select('root')
->from('Acme', 'root', 'root.id');
/.../
}

#After
public function findAllIndexById(){
$qb = $this->createQueryBuilder('root','root.id');
/.../
}

Flo flo-pereira Update lib/Doctrine/ORM/EntityRepository.php
simply permit an indexby directly from the repo object

Ex : 
#Acme\AcmeBundle\Repository
#Before
public function findAllIndexById(){
    $qb = $this->_em->createQueryBuilder()
                    ->select('root')
                    ->from('Acme', 'root', 'root.id');
    /*...*/
}

#After
public function findAllIndexById(){
    $qb = $this->createQueryBuilder('root','root.id');
    /*...*/
}
8b8c741
doctrinebot
Collaborator

Hello,

thank you for positing this Pull Request. I have automatically opened an issue on our Jira Bug Tracker for you with the details of this Pull-Request. See the Link:

http://doctrine-project.org/jira/browse/DDC-2279

Benjamin Eberlei
Owner

This would unnecesarily bloat the API. You can use the way through $entityManager->createQueryBuilder().

Benjamin Eberlei beberlei closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 5, 2013
  1. Flo

    Update lib/Doctrine/ORM/EntityRepository.php

    flo-pereira authored
    simply permit an indexby directly from the repo object
    
    Ex : 
    #Acme\AcmeBundle\Repository
    #Before
    public function findAllIndexById(){
        $qb = $this->_em->createQueryBuilder()
                        ->select('root')
                        ->from('Acme', 'root', 'root.id');
        /*...*/
    }
    
    #After
    public function findAllIndexById(){
        $qb = $this->createQueryBuilder('root','root.id');
        /*...*/
    }
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 3 deletions.
  1. +4 −3 lib/Doctrine/ORM/EntityRepository.php
7 lib/Doctrine/ORM/EntityRepository.php
View
@@ -75,14 +75,15 @@ public function __construct($em, Mapping\ClassMetadata $class)
* Creates a new QueryBuilder instance that is prepopulated for this entity name.
*
* @param string $alias
- *
+ * @param string $indexBy The index for the from.
+ *
* @return QueryBuilder
*/
- public function createQueryBuilder($alias)
+ public function createQueryBuilder($alias, $indexBy = null)
{
return $this->_em->createQueryBuilder()
->select($alias)
- ->from($this->_entityName, $alias);
+ ->from($this->_entityName, $alias, $indexBy);
}
/**
Something went wrong with that request. Please try again.