Am I missing a point with Doctrine? It’s been very useful for some scenarios, but for the basic scenario of retrieving an entity using an Id (say using find() or findOneBy()) why do you see a query being fired off for every relationship to populate the main entity’s properties?
Surely with the mapping/annotations I’ve created, Doctrine should be capable of a few joins and one query, without having to write a DQL query for the retrieval of each entity.
Or, as I’m predicting, have I missed the point somewhere!
Just add the aliases of related entities to
selectpart of your query.Let’s say, you have
Bookrelated one-to-many toCover, and you want so select some books with their covers.With query builder, use:
With query, use:
As the result, you will receive collections of
Bookwith prepopulated$coverscollection.