Orm doctrine: traversing lazy getter and prefetch entries in getter

Working with Doctrine ORM, is it possible to enable automatic loading of related records when used in a getter? (without explicit leftJoins ())

I know that I can use leftJoin () to get an object with related records, but I want to avoid creating a DQL query for each object and just some automatic “prefetch” of the related records.

This is useful when you need to iterate over nested Doctrine_Records and this is exactly the same functionality as Kohana ORM via the with () statement:

http://docs.kohanaphp.com/libraries/orm#with

(It just executes the query with joins, even if you only get the “root” record with array syntax).

+3
source share
1 answer

I'm not sure I understood, but you can find the answer in the doc doctrine :

$users->loadRelated('Phonenumbers');
-1
source

Source: https://habr.com/ru/post/1720175/


All Articles