-
-
Save iron-viper/fd58862d75d73695fa343ea0bf8e4825 to your computer and use it in GitHub Desktop.
Doctrine2 get all the child records from adjacency list.
This file contains hidden or 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