[eluser]theprodigy[/eluser]
To more changes:
1. Change all your $r->id into $r['id'] as $r is now an array
2. You switched the parameters in the function declaration, but you are still calling it down below by the original way
Code:
function generateTree(&$tree, $parentid = 0) {...}
is correct, but you need to also change
Code:
$this->generateTree($r->id, $tree[$r->id]['children']);
to
Code:
$this->generateTree($tree[$r['id']]['children'], $r['id']);
Change those and let's see where we are at.