我正在尝试使用<button class="btn btn-danger" (click)="removeUser()"> Delete</button></td>前端从我的数据库中通过 id 删除一个对象, 但链接不起作用。我收到一个错误:The identifier id is missing for a query of PrManagerBundle\Entity\eb_user.这是我的实体:namespace PrManagerBundle\Entity;use Doctrine\ORM\Mapping as ORM;/** * eb_user * * @ORM\Table(name="eb_user") * @ORM\Entity(repositoryClass="PrManagerBundle\Repository\eb_userRepository") */class eb_user{ /** * @var int * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id;/** * @var string * * @ORM\Column(name="nom", type="string", length=255) */private $nom;/** * @var string * * @ORM\Column(name="prenom", type="string", length=255) */private $prenom;/** * @var int * * @ORM\Column(name="tel", type="string", nullable = true) */private $tel;/** * @var string * * @ORM\Column(name="mail", type="string", length=255, nullable = true) */private $mail;/** * @var string * * @ORM\Column(name="domaine", type="string", length=255, nullable = true) */private $domaine;/** * @ORM\ManyToOne(targetEntity="PrManagerBundle\Entity\eb_role", inversedBy="eb_user") */private $x_eb_role;/** * Get id * * @return int */public function getId(){ return $this->id;}/** * Set nom * * @param string $nom * * @return eb_user */控制器:public function removeAction(Request $request) { $em = $this->getDoctrine()->getManager(); $userInfo = json_decode( $request->request->get("user") ); $eb_user = $em->getRepository('PrManagerBundle:eb_user')->find($request->request->get('id')); $em->remove($eb_user); $em->flush(); $em->clear(); return $this->returnJsonResponse($eb_user); /* $repository = $this->getDoctrine()->getRepository(eb_user::class); $editUser = $repository->find($id); return $this->returnJsonResponse($editUser);*/ }路由在这里:pr_manager_remove: 路径: /user/remove/{id} 默认值: { _controller: PrManagerBundle:User:remove }实际上没有找到id。我希望链接正常工作
1 回答
- 1 回答
- 0 关注
- 123 浏览
添加回答
举报
0/150
提交
取消