-
-
Save billhance/986db278ef9de9ed2d6d1e82c86a4fe7 to your computer and use it in GitHub Desktop.
Doctrine2 get all the child records from adjacency list.
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
public function getSubOrgsForTranspnakl(Entity $topitem) | |
{ | |
$childrenArray = array(); | |
$iterate = true; | |
$listOfParents = array(); | |
$listOfParents = array_push($listOfParents, $topitem); | |
while ($iterate){ | |
$q = $this | |
->createQueryBuilder('o') | |
->where('o.parent IN (:parentslist) ') | |
->setParameter('parentslist', $listOfParents) | |
->getQuery(); | |
$resultArray = $q->getResult(); | |
$listOfParents = $resulArray; | |
$childrenArray = array_merge($childrenArray, $resultArray); | |
if (count($resulArray) == 0) $iterate = false; | |
} | |
return $resultArray; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment