[英]Symfony - can't delete record
I am testing delete action in Postman. 我正在邮递员中测试删除操作。 I created a delete action and it keeps returning 'success' and when I refresh the database my row with forwarded parameter(of id = 1) is still there.
我创建了一个删除操作,它始终返回“成功”,并且当我刷新数据库时,带有转发参数(id = 1)的行仍然存在。
My Service. 我的服务。
/**
* Delete user
* @param $id
* @return mixed
*/
public function deleteUser($id)
{
$query = $this->getUserRepository()
->createQueryBuilder('du')
->delete('ProjectBundle:User','du')
->where('du.id = :id')
->setParameter("id", $id)
->getQuery()
->execute();
return $query;
}
Controller. 控制器。
/**
* @Route("/users/delete/{id}", name="user_delete")
* @param $id
* @return \Symfony\Component\HttpFoundation\JsonResponse
* @throws \Doctrine\Common\Annotations\AnnotationException
*/
public function getUserDeleteAction($id)
{
$this->get('user')->deleteUser($id);
return $this->success();
}
I think this is the right way and don't know where the problem could be. 我认为这是正确的方法,不知道问题可能在哪里。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.