Doctrine Query Builder Delete Statement
Solution 1:
For the delete statement is different from the select, you don't specify the column name for the delete unlike select.
Corrected Code
$qd = $repository->createQueryBuilder('n');
$qd->delete()
->where('n.id = :id')
->setParameter('id',$newsID);
$query = $qd->getQuery();
$result = $query->getResult();
Another Format
$query = $this->getDoctrine()->getManager()->createQuery('delete FROM LesDataBundle:News n where n.id = '.$newsID);
$result = $query->getResult();
For the Update Statement it is :
$qd = $repository->createQueryBuilder('n');
$qd->delete()
$qd->update()
->set('n.text' , ':text')
->where('n.id = :id')
->setParameters( array('id'=> $newsID, 'text' => 'Hello World') );
$query = $qd->getQuery();
$result = $query->getResult();