I'm using symfony 2.0.10 to build a site and in my controller I'm querying a database table using this code:
$query = $this->getDoctrine()->getRepository('MyBundle:MyTable')->createQueryBuilder('x')->getQuery();
$data = $query->getResult();
I would get the results indexed in the array not by sequential numbers (0 to N) but instead by a specified field. I saw that I can do this specifing a INDEX BY in the CreateQuery method but how can I do this with the query builder? In this question a reply is given but the user is not using a repository.
EDIT 1
$query = $this->getDoctrine()->getEntityManager()->createQueryBuilder()->select('x')->from('MyBundle:MyTable', 'x', 'x.myIndexField')->getQuery();