-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for using nested DTOs #11576
Conversation
This feature allow use of nested new operators Co-authored-by: Tomas Norkūnas <[email protected]> Co-authored-by: Sergey Protko <[email protected]> Co-authored-by: Łukasz Zakrzewski <[email protected]> Update docs/en/reference/dql-doctrine-query-language.rst Co-authored-by: Claudio Zizza <[email protected]>
Thanks @eltharin ! |
$query = $em->createQuery('SELECT NEW CustomerDTO(c.name, e.email, NEW AddressDTO(a.street, a.city, a.zip)) FROM Customer c JOIN c.email e JOIN c.address a'); | ||
$users = $query->getResult(); // array of CustomerDTO | ||
|
||
Note that you can only pass scalar expressions or other Data Transfer Objects to the constructor. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eltharin sorry, I forgot this during my review, but below there is a paragraph called EBNF
with a grammar that you should probably update with your changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK => #11619
Now that we use phpDocumentor/guides and doctrine/orm#11576 is merged, we can try using captions instead of custom directives.
With add support for using nested DTOs, how to use it with Currently I have this: $result = $this->entityManager->createQueryBuilder('c')
->select(sprintf(
'NEW %s(c.name, e.email)',
CustomerDTO::class
))
->join('c.email', 'e')
->getQuery()
->getResult(); I would like to add |
Have you tried:
|
It works perfectly! |
For #11540 in good branch