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

后端 未结 4 2039
梦如初夏
梦如初夏 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:25

    The findAll() method does not have any parameters. You can, for example, use the repository's createQueryBuilder() method to achieve what you want to do:

    use Doctrine\ORM\Query;
    
    // ...
    
    $query = $this->getDoctrine()
        ->getRepository('CoreBundle:Categories')
        ->createQueryBuilder('c')
        ->getQuery();
    $result = $query->getResult(Query::HYDRATE_ARRAY);
    

提交回复
热议问题