smartcoderx
smartcoderx

Reputation: 1081

Can find by return an arraycollection instead of array

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?

Upvotes: 11

Views: 12003

Answers (1)

vdwijngaert
vdwijngaert

Reputation: 1555

You could just do

$collection = new ArrayCollection($allQuestions);

To convert the array to an ArrayCollection.

Upvotes: 20

Related Questions