$query = $this->getEntityManager()->createQueryBuilder();
$query->delete(Ip::class, 'ip')
->where('ip.date BETWEEN :startDate AND :endDate')
->setParameters([
'startDate' => $dateStart,
'endDate' => $dateEnd,
])
->andWhere('ip.wpisywacz_id = :wpisywacz_id')->setParameter('wpisywacz_id', $userName)
->andWhere('ip.category_id = :category_id')->setParameter('category_id', $categoryId)
->andWhere('ip.ip = :ip ORDER BY ip.id ')->setParameter('ip', $ip)
//->>orderBy('ip.id', 'desc')
//->addOrderBy('ip.id','DESC')
//->addOrderBy('ip.id','desc')
->setMaxResults(1);
;
dump($query->getQuery()->getSQL());
die;
$query->getQuery()->execute();