Reputation: 13320
Let's say I have a User entity and a Comments entity, with a relationship of one-to-many.
Let's also say that I am using Doctrine 2 to pull my User entity from the DB, and I am opting to lazy-load my user's comments, vs pull everything all at once.
I now have a specific page where I want to show the user's last comment, and upon asking the User for it's comments, the lazy-loading proxy kicks in and pulls the comments from the database.
This is where my problem starts: for most people who have 1-5 comments, this is fine...however, if the person has hundreds or thousands of comments, how do I use lazy-loading when I don't want to load all the comments at once?
Is this beyond Doctrine 2?
Upvotes: 0
Views: 173
Reputation: 43243
The lazy loading mechanism is only capable of loading the full set. In order to only load the last one you would need to use a DQL query.
Upvotes: 1