How can I write this in my Repository to be able to work with it in my controller ?
SELECT COUNT(id_pnc)
FROM programmevol p
WHERE p.id_pnc IN (
SELECT id_pnc
FROM programmevol A
WHERE p.id_pnc=A.id_pnc
HAVING COUNT(*)>1
);
Try with this:
public function findWhateverYouWant()
{
$em = $this->getEntityManager();
$rsm = new ResultSetMappingBuilder($em);
$sql = sprintf('SELECT COUNT(id_pnc)
FROM programmevol p
WHERE p.id_pnc IN ( SELECT id_pnc
FROM programmevol A
WHERE p.id_pnc=A.id_pnc
HAVING COUNT(*)>1
)',
$rsm->generateSelectClause()
);
$query = $em->createNativeQuery($sql, $rsm);
return $query->getResult();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.