如何编写Doctrine2删除查询

时间:2013-06-19 02:47:08

标签: orm doctrine-orm

如何在Zend中的doctrine2中编写查询DELETE FROM table WHERE id = 2

$this->_em->getrepository(something\entitity\something\table)->remove()->where('id',2) ?

1 个答案:

答案 0 :(得分:6)

DELETE queries

$repository = $this->_em->getRepository('My\\Entity');
$query = $repository->createQuery('DELETE FROM entity e WHERE e.id = ?1');
$query->setParameter(1, $id);
$query->execute();