How to get Parent id of node in doctrine nested set
I have the following code :
$treeObject = Doctrine_Core::getTable('Category')->getTree();
$rootColumnName = $treeObject->getAttribute('rootColumnName');
foreach ($treeObject->fetchRoots() as $root) {
$options = array( 'root_id' => $root->$rootColumnName );
foreach($treeObject->fetchTree($options) as $node) {
$parent_id = $node->getNode()->getP开发者_StackOverflowarent()->getId();
echo $parent_id;
}
}
This works fine however the getparent() call executes a query for every node. is there away to retrieve the parent id with out running hundreds of extra queries.
精彩评论