How to merge two php Doctrine 2 ArrayCollection()

前端 未结 8 1036
误落风尘
误落风尘 2020-12-08 01:21

Is there any convenience method that allows me to concatenate two Doctrine ArrayCollection()? something like:

$collection1 = new ArrayCollection         


        
8条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-08 02:07

    Better (and working) variant for me:

    $collection3 = new ArrayCollection(
        array_merge($collection1->toArray(), $collection2->toArray())
    );
    

提交回复
热议问题