1
我有问题使用Symfony2从我的数据库删除记录。希望有人能帮助我。Symfony2删除记录
这里是我的代码:
// Get user's account
$account = $this->getUser()->getAccount();
// Get manager
$em = $this->getDoctrine()->getManager();
// Get entity
$entity = $em->getRepository('WICPurchaseOrderLineItemBundle:PurchaseOrderLineItem')->findBy(array('account'=>$account->getId(), 'id'=>$id));
// If not entity
if (!$entity) {
throw $this->createNotFoundException('Unable to find this entity.');
}
// Remove the record...
$em->remove($entity);
$em->flush();
// Go to this url...
return $this->redirect($this->generateUrl('purchaseOrder_view', array('id' => '8')));
当这样跑,我得到这个错误:
EntityManager#remove() expects parameter 1 to be an entity object, array given.
我的URL看起来像这样:
{{ path('purchase_order_remove_line_item', { 'id': purchaseOrderLineItem.id }) }}
请问我的“身份证“数字需要先变成一个对象?不知道如何解决这个问题,仍然在学习Symfony。
任何人有任何建议吗?