Site icon Shyam Makwana

SubQuery in Doctrine 2.x using getDQL()

<?php
 
$queryBuilder = $this->entityManager->createQueryBuilder();
$queryBuilder2 = $this->entityManager->createQueryBuilder();


$subQuery = $queryBuilder2->select('COUNT(fr.status)')
            ->from(FeedbackRequest::class, 'fr')
            ->where('fr.giverId = iu.userId')
            ->groupBy('fr.status')
         
$Query = $queryBuilder->select('iu')
        ->addSelect("(".$subQuery->getDQL().") statusCount")
        ->from(InstitutionUser::class, 'iu')
        ->setMaxResults(10)
        ->getQuery()
        ->getResult()
        ;
Exit mobile version