1
我无法在控制器内持久保存多个实体。我只能保存最后一个。在symfony2中保留多个实体
我的代码:
$product = new Product();
$names = ['yellow', 'blue', 'red']; // save these to the table
foreach ($name as $name) {
$product->setName($name);
$em->persist($product);
// $em->flush(); // doesn't work either
}
$em->flush();
我使用Symfony的2.7
喔,谢谢,现在的作品...很简单:) –