我使用這個:返回數組,而不是從教義查詢對象 - Symfony2的
$this->getDoctrine()->getRepository('MyBundle:MyEntity')->findAll(array(), Query::HYDRATE_ARRAY);
我認爲,應該確保它返回一個數組的數組,但它仍然會返回對象的數組。
我需要返回一個數組,所以我可以做這種事情的數組整個結果(愚蠢的例子,但它說明了我的意思):
<?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']; ?>
我有同樣的問題,它給了我這個錯誤「Error:Class'apb \ appassBundle \ Controller \ Doctrine \ ORM \ Query'not found in controller」 – numerah
在'\ Doctrine \ ORM \ Query上使用前導斜槓' –
thanx它也工作時,我添加使用類,只是添加查詢:: HYDRATE_ARRAY – numerah