如何获取学说嵌套集中节点的父ID
我有以下代码:
$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。
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()->getParent()->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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论