开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜