我是symfony的新手,我被困在删除选项中,我写了一个工作正常的查询但我需要在不同的表中删除相同的记录(我在2个表中有相同的记录)
我的控制器
public function deleteAction(Request $request){
$deleteQuery = $this->getDoctrine()
->getManager()
->createQueryBuilder('d')
->delete('TcPlayerBundle:TcTracks', 'd')
->where('d.id = ' . $request->get('id'))->getQuery();
$deleted = $deleteQuery->getResult();
$deleted->flush();
return $this->render('TcPlayerBundle:Default:all.html.twig',array(
'tracks' => $tracks
));
}
这个查询对于单个表工作正常,如何与另一个表进行内连接 TcprofileBundle:TcWall和该表中的id是related_id。请帮助我解决方案,谢谢
答案 0 :(得分:0)
这样做:
$em = $this->getDoctrine()->getManager();
$tcTrack = $em->getRepository('TcPlayerBundle:TcTracks')->find($request->get('id'));
$em->remove($tcTrack);
$em->flush();