S
S
serp in2015-11-30 09:29:00
symfony
serp in, 2015-11-30 09:29:00

How to get a result with only one type of entity in Doctrine 2 when selecting multiple entities?

Those. I get a pseudo-request

SELECT a, c
FROM Aticle a
JOIN Comments c

It is necessary that when working with the result, only the Articleentity is in it, but Commentsit is already attached to Article.
Fetch Eager is not suitable because less productive due to additional queries to the database, like lazy.
Some kind of crutch, like instanceof, is also not suitable, and if I want the result in the form of an array, I will have to check the signature there too. Not an option.
Or watch result mapping?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis, 2015-11-30
@prototype_denis

you here

A
Andrey Kulikovsky, 2015-12-01
@by25

Such request just also does that you described.
It turns out an Article[] array with comments bound to the Article entity

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question