Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Doctrine SubQuery 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()
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment