我使用这个:
@H_301_1@$this->getDoctrine()->getRepository('MyBundle:MyEntity')->findAll(array(),Query::HYDRATE_ARRAY);
我认为应该确保它返回一个数组的数组,但它仍然返回一个对象数组.
我需要整个结果作为数组的数组返回,所以我可以做这样的事情(愚蠢的例子,但它解释了我的意思):
@H_301_1@<?PHP $result = $this->getDoctrine()->getRepository('MyBundle:MyEntity')->findAll('return-an-array'); ?> This is the age of the person at the 5th record: <?PHP echo $result[4]['age']; ?> @H_403_9@@H_403_9@
根据这个
EntityRepository class,findAll不要多个参数.
下面的代码应该做你想要的
@H_301_1@$result = $this->getDoctrine() ->getRepository('MyBundle:MyEntity') ->createQueryBuilder('e') ->select('e') ->getQuery() ->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY); @H_403_9@