开发者

doctrine orm: bypass lazy loading and prefetch related records in a getter

开发者 https://www.devze.com 2022-12-08 08:54 出处:网络
Working with Doctrine ORM, is it possible to enable auto eager loading of related records when using in a getter ? (without explicit leftJoins())

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

I know I can use a leftJoin() to obtain the object with related records, but I want to avoid creating a DQL query for every object and simply have some kind of automatic "prefetching" of related records.

This is useful when you have to cycle through nested Doctrine_Records and it's exactly the same functionality that Kohana ORM has through th开发者_JAVA技巧e with() statement:

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

(It simply executes the query with the joins even if you get only the 'root' record with the array syntax).


I'm not sure I understood but you may find answer in doctrine doc :

$users->loadRelated('Phonenumbers');
0

精彩评论

暂无评论...
验证码 换一张
取 消