This snippet from official website works as expected:
$treeObject = Doctrine::getTable('Category')->getTree();
$rootColumnName = $treeObject->getAttribute('rootColumnName');
foreach ($treeObject->fetchRoots() as $root) {
$options = array(
'root_id' => $root->$rootColumnName
);
foreach($treeObject->fetchTree($options) as $node) {
echo str_repeat(' ', $node['level']) . $node['name'] . "\n";
}
}
But I see there are dozens of queries sent to database.
How can I do it in a mouthful?