Return array, not object from Doctrine query - Symfony2

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

I\'m using this:

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

I thought that sh

3条回答
  •  -上瘾入骨i
    2021-02-12 21:03

    You can also use the getArrayResult() function instead of getResult(). It returns an array of data instead:

    $query = $em->createQuery("SELECT test FROM namespaceTestBundle:Test test");
    $tests = $query->getArrayResult();
    

提交回复
热议问题