Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write a Doctrine2 delete query

How do i write a query DELETE FROM table WHERE id = 2 in doctrine2 in Zend ?

$this->_em->getrepository(something\entitity\something\table)->remove()->where('id',2) ?
like image 408
Samosa Avatar asked Jun 19 '13 02:06

Samosa


1 Answers

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();
like image 193
K. Norbert Avatar answered Nov 17 '22 12:11

K. Norbert