11

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?

2
  • You can convert it to an Arraycollection right ? Commented Apr 22, 2015 at 7:09
  • ArrayCollection it is an array of objects, you alredy getting the ArrayCollection, check the stackoverflow.com/questions/29180651/arraycollection-in-symfony/… response for more details about what it is an array collection Commented Apr 22, 2015 at 8:37

1 Answer 1

20

You could just do

$collection = new ArrayCollection($allQuestions);

To convert the array to an ArrayCollection.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.