如何在doctrine嵌套集中获取节点的父ID

时间:2011-02-26 08:31:28

标签: doctrine nested-sets

我有以下代码:

$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()->getParent()->getId();
    echo $parent_id;
  }
}

这很好,但是getparent()调用会为每个节点执行查询。是否可以通过运行数百个额外查询来检索父ID。

0 个答案:

没有答案