在控制器中我会这样做:
$nodes = $this->getDoctrine() ->getRepository('MyFreelancerPortfolioBundle:TreeNode') ->findAll(); $em = $this->getDoctrine()->getManager(); foreach($nodes as $node) { $em->remove($node); } $em->flush();
从我得到的命令中的execute()函数执行此操作:
Call to undefined method ..... ::getDoctrine();