How to get Array Results in findAll() - Doctrine?

后端 未结 4 2031
梦如初夏
梦如初夏 2021-01-18 03:53

I need to fetch all records in database as Array using findAll() in Doctrine, My Query is Something like this

$result = $this->getDoctrine()
         


        
4条回答
  •  终归单人心
    2021-01-18 04:23

    The format in which the result of a DQL SELECT query is returned can be influenced by a so-called hydration mode so you couldn't use it for findAll().you may try this below:

    $em = $this->getDoctrine()->getManager();
    $result = $em->createQuery('select m from CoreBundle:Categories m')
            ->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY);
    

提交回复
热议问题