Last active
May 18, 2021 18:10
-
-
Save technoknol/141d01822e495d5e9111fd43177331cf to your computer and use it in GitHub Desktop.
Doctrine SubQuery using getDQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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