I've recently started rebuilding a old PHP application using Silex, Doctrine and Twig.
One of the main entities is "issue" (It's a issue tracking system), the issue has relations to many other entities, like "status", "Owner", "creator" , etc. I've created all entities as doctrime ORM entities and defined all relationships.
From the controller, I fetch one "issue" and send it to the twig template like this:
$issue = $app['orm.em']->getRepository('MMW\Entity\Issue')->find($issueId);
In the twig template i can easily print out the related entities, like:
{{ issue.status.name }}
and
{{ issue.owner.name }}
It works like a charm, but when I enable logging to see what queries are send to the database like this:
$em->getConnection()
->getConfiguration()
->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger());
I notice that for each join, a separate query is send to the database. I would think that performance wise, one query with SQL joins would be much faster.
Should I build my application in a different way, maybe use the querybuilder in the controller to fetch the exact columns and entities I need? Or is there a way to force doctrine to build the query in a different way?
Or should I just not worry about it and leave it as is...?