2013-06-19 47 views
6

如何在Zend中的doctrine2中編寫查詢DELETE FROM table WHERE id = 2如何編寫Doctrine2刪除查詢

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

回答

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(); 
+0

THX!有用 ! – Samosa