开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜