Suppose the following structure database structure - whereby a category has many articles, and an article has many comments:
Category:
- id
Article:
- id
- category_id
Comment:
- id
- created_at
- article_id
Using Doctrine, what is the best/standard way to:
By comparison in Laravel, I could've set up a relation on the Category entity to have one Comment through the Article, and ordered it by the created date. However, I do not know how to achieve this via Doctrine or DQL.
I'm afraid there is no "standard way" for it with eager load. I mean no way to setup it with some config/annotations.
I'd do it in following way:
getMostRecentCommentsForCategories(array $categories)
and getMostRecentCommentsForArticles(array $articles)
methods in it