Tag
Doctrine
4 posts tagged Doctrine.

09/02/2026
The N+1 you wrote in a Twig loop, and its fix
The query looks fine and the template looks fine. Together they issue one query per row, because a lazy association is loaded the moment a template touches it - and templates touch things the controller never did.

01/25/2016
Doctrine: joining entities with no association
In Symfony using Doctrine, if no association is available for two entities, you can still join them and treat them like they have a relationship. To do so, you have to use the “Join: WITH” method.

01/01/2015
Limiting a Doctrine query with setMaxResults
Here is an example of a simple DQL query in a custom repository method meant to return a single array result. The following will return the latest result in case there are multiple contact records that match the…

11/19/2013
Knowing whether a Doctrine insert or update worked
Doctrine has no return value to check after flush() - it signals failure by throwing. Wrapping it is the right instinct, but the version of this snippet that has been circulating since 2013 catches nothing at all.