当前位置: 动力学知识库 > 问答 > 编程问答 >

symfony2 - 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?

网友答案:

You could just do

$collection = new ArrayCollection($allQuestions);

To convert the array to an ArrayCollection.

分享给朋友:
您可能感兴趣的文章:
随机阅读: