When I try to run this query in my action controller, my browser page freezes:
$query = $em->createQuery('SELECT c FROM Baza\BlogBundle\Entity\Conferences c WHERE c.locationid= ?1');
$query->setParameter(1, 5);
$id = $query->getResult();
But when I perform any other query like:
$query = $em->createQuery('SELECT c.title FROM Baza\BlogBundle\Entity\Conferences c WHERE c.locationid= ?1');
$query->setParameter(1, 5);
$id = $query->getResult();
everything seems to be in order. The only difference is that in the first one I retrieve whole object, not just single field.
This problem is happening for all tables, not just this one. What should I do?
It is very unlikely the query is causing the hang, but rather what you do with the result after. If you are ever ‘printing’ a symfony object, your browser will hang because of all the recursion. Your second query fetches just the title, so you won’t be printing the object, just a text field.
A simple fix would be to change the last line of your first query:
(or whatever function make sense). Would need to see more code if this does not solve the problem.