如何在控制器中编辑需求的许多注释

时间:2014-03-29 14:53:30

标签: symfony

我会显示要求和所有评论

$em = $this->container->get('doctrine')->getManager();
$valider = $em->find('PublishDemandsBundle:Demands', $id);
$comments = $em->getRepository('PublishDemandsBundle:Pcomment')->findByDemands($valider);

我需要编辑所有评论的表评论中所见的语句:$ comments如何使其编辑所有评论的需求:

$comments ->setSeen(true);
$em->persist($comments);
$em->flush();

1 个答案:

答案 0 :(得分:1)

循环:

foreach ($comments as $comment) {
  $comment->setSeen(true);
}
$em->flush();