I have a entity like this:
Person
- id_person
- name
- child //self refering
If I query person entity in a recursive funcion it only returns me the first three levels. Do you know how to tell to doctrine that I want to get deep as many levels is required?
Edit
What was the problem?
Using $queryBuilder->getquery()->getResult(Query::HIDRATE_ARRAY); is not the best way to make a recursive function, it should use the default hydration.
How I resolve it?
Using $queryBuilder->getquery()->getResult(); and call the getters as @Andreas Linden say: $parent->getChild()
all associations will be lazy loaded when you access them from within your model 8if you don’t define it to behave differently). so always use getter methods like
getChild()which simply doesreturn $this->child;you can also left-join as many levels as you require so you won’t generate thousands of queries (a single query for each child)