[DDC-2322] [GH-592] Added ability to specify INDEX BY when creating a QueryBuilder from a Repository Created: 27/Feb/13 Updated: 12/Mar/13 Resolved: 12/Mar/13 |
|
| Status: | Resolved |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.2, 2.3, Git Master |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Improvement | Priority: | Minor |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Invalid | Votes: | 0 |
| Labels: | QueryBuilder, Repository | ||
| Description |
|
This issue is created automatically through a Github pull request on behalf of cmenning: Url: https://github.com/doctrine/doctrine2/pull/592 Message: This is a handy shortcut when using indexed results. |
| Comments |
| Comment by Benjamin Eberlei [ 12/Mar/13 ] |
|
A related Github Pull-Request [GH-592] was closed |
| Comment by Craig Menning [ 12/Mar/13 ] |
|
I disagree with the reasoning behind closing this request. In DoctrineBundle, getDoctrine()->getEntityManager() has been deprecated, which leaves you to use getDoctrine()->getRepository($class)->createQueryBuilder(); Adding ->from() at that point is redundant since it's already been specified inside the createQueryBuilder() call. It seems wasteful to not allow a passthru of the $indexBy argument during the initial call when it's already supported by the from() called inside createQueryBuilder(). |
| Comment by Marco Pivetta [ 12/Mar/13 ] |
|
The repository is already (probably) doing too much. A simpler approach with: $qb = $em->createQueryBuilder()->select('e')->from($repo->getClassName(), 'e', 'e.stuff')
Is no big deal in my opinion. |
[DDC-2140] [GH-512] Added addParameters() to Query and QueryBuilder Created: 13/Nov/12 Updated: 20/Nov/12 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.3, Git Master |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Improvement | Priority: | Minor |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | Query,, QueryBuilder | ||
| Environment: |
OS X 10.8.2, PHP 5.3.18, Nginx 1.2.4 (php through FPM) |
||
| Description |
|
This issue is created automatically through a Github pull request on behalf of jappie: Url: https://github.com/doctrine/doctrine2/pull/512 Message: This method behaves like setParameters() before version 2.3: It can take a Doctrine\Common\Collections\ArrayCollection with Doctrine\ORM\Query\Parameter objects, as well as a plain array with key/value pairs, as argument. This will greatly ease the upgrade to Doctrine 2.3, because you only need to perform a project-wide replace of setParameters with addParameters, in stead of going into your code and determine if calls to setParameters are ok or need refactoring. I've also added unit-tests to maintain integrity. |
| Comments |
| Comment by Benjamin Eberlei [ 20/Nov/12 ] |
|
A related Github Pull-Request [GH-512] was closed |
| Comment by Jasper N. Brouwer [ 20/Nov/12 ] |
Hi Guilherme, I agree that such a method makes less sense in Query, because when you write a DQL string all parameters are known at once. But when using the QueryBuilder you might need different parameters in different cases, so addParameters() becomes useful there. I guess it's just a convenience method, like IMHO setParameter() is. (You could just do $qb->getParameters()->add()) The main reason for adding the method was, like I said, upgrading to Doctrine 2.3. I've already upgraded all my projects to Doctrine 2.3, so the method is less useful for me now. But it took me a full day to refactor my repositories, because there is no safe way to automate the process. A simple search-and-replace setParameters() to addParameters() would have taken me 5 minutes I'm content with your decision. |