D
D
Dsazz2015-03-19 21:06:47
symfony
Dsazz, 2015-03-19 21:06:47

How to filter nested entity objects?

Hello! Tell me how and with what it is possible to filter nested entity objects in Doctrine ORM, so that there is one request? For example, there is an Event associated with it Users, users have Documents. Documents and Events have Tags. As a result, you need to filter both documents and events by tags at the same time. Is it possible ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Skobkin, 2016-02-28
@skobkin

Possibility of filtering in collections is provided. But this will not be a single request (unless you have fetch="EAGER", but it's better not to do this all the time).
So in your case it's better to take QueryBuilder . join tables and filter.
Although, again, if my memory serves me, if not all the contents are selected, then the collection will not be hydrated. So you can choose either one side of the connection or the other. Or you can choose without conditions and filter already in the code. But it makes sense to do it only if there is definitely not too much data.
By the way, why do you so stubbornly want exactly one request, and not two?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question