Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can find by return an arraycollection instead of array

Tags:

symfony

I retrieve all objects for an entity like this:

$allQuestions = $em->getRepository('AppMyBundle:Question')
    ->findBy(array('isActive' => true, 'isDeleted' => false));

I get an array of objects into $allQuestions. Is there a possibility to get an ArrayCollection instead of an array?

like image 208
smartcoderx Avatar asked Apr 22 '15 07:04

smartcoderx


1 Answers

You could just do

$collection = new ArrayCollection($allQuestions);

To convert the array to an ArrayCollection.

like image 77
vdwijngaert Avatar answered Nov 17 '22 13:11

vdwijngaert