Return array, not object from Doctrine query - Symfony2

前端 未结 3 678
伪装坚强ぢ
伪装坚强ぢ 2021-02-12 20:02

I\'m using this:

$this->getDoctrine()->getRepository(\'MyBundle:MyEntity\')->findAll(array(), Query::HYDRATE_ARRAY);

I thought that sh

3条回答
  •  误落风尘
    2021-02-12 21:02

    According to this EntityRepository class, findAll don't take multiple arguments.

    The code below should do what you want

    $result = $this->getDoctrine()
                   ->getRepository('MyBundle:MyEntity')
                   ->createQueryBuilder('e')
                   ->select('e')
                   ->getQuery()
                   ->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY);
    

提交回复
热议问题