I try to delete some data with Doctrine\DBAL\Connection
, I want to delete the duplicate data so I have to delete n-1 data (If n data are the same).
public function deleteDuplicateData(array $data) : bool
{
$qb = $this->connection->createQueryBuilder();
$qb->delete('myTable')
->where('id= :id')
->setParameter('id', $data['id'])
->setMaxResults($data['n']-1)
;
return $qb->execute();
}
However the ->setMaxResults($data['n']-1)
doesn't work, when I run my code all data are deleted. I tried this ->setMaxResults($data['n']-1)
but it does'nt work so I think the method ->setMaxResults()
doesn't work for the delete method.