Reputation: 1054
I need to grab data from a symfony 2 db. The data looks like :
Parent-Element [id 15]
-> Child Element [id 20, parent ID 15]
--->Child Element [id 27, parent ID 20]
----->Child Element [id 34, Parent ID 27]
....
The Childs are assigned to each parent Element by a cathegory ID see [ ]. There might be more than one Child Elements per level.
In php it would be easy to grab this by a while loop. But in Symfony im stucking. Can anyone help me finding a solution? IS there a while loop in symfony?
Kind regdards
Philipp
EDIT: I mean, in "normal" php I would do a simple while or create an array with ids which I loop through by another while loop... In smyfony, I would use a queryBuilder like that
$query = $em->createQueryBuilder()
->select('d')
->from('PrUserBundle:Location', 'd')
->where('d.client_id = :client_id')
->setParameter('client_id', $this->clientId)
->getQuery();
$results=$query->getResult();
Where I don't see any possibility to grab any other Ids or sort it so that I can render a parent-child listing.
Upvotes: 0
Views: 650