S
S
startproger2020-01-05 13:17:55
symfony
startproger, 2020-01-05 13:17:55

How to prevent Doctrine from making an additional request to populate an ArrayCollection?

Doctrine 2.7
Let's say there are two entities Foo and Bar
Foo has OneToMany $bars (which itself is an ArrayCollection)
Bar respectively has ManyToOne $foo.
In the repository, using the query builder, I create a request to get a record from Foo.
If the request to Foo has joins of Bar links (and their select) and where conditions are met on them, then when getting through the $bars getter, only those records from Bar that were selected in the request get into the ArrayCollection.
If the links from Bar in the request were not added to the select and/or were not joined at all, then when the getter $bars is received, the doctrine itself executes another request to get all the links from Bar and returns them.
Question: how to prevent it from making this additional request and if the links were not selected in the request itself, give an empty array?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
index0h, 2020-01-05
@index0h

https://www.doctrine-project.org/projects/doctrine...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question