【问题标题】:Fetching doctrine nested set with one query使用一个查询获取学说嵌套集
【发布时间】:2011-03-10 15:13:02
【问题描述】:

我正在寻找一种在一个数据库查询中获取嵌套集的方法。

schema.yml
Category:
  actAs:
    NestedSet:
      hasManyRoots: true
      rootColumnName: root_id
  columns:
    name: string(255)

$categories = Doctrine::getTable('Category')->getTree();

//SELECT * FROM category c ORDER BY c.root_id asc, c.lft asc

foreach ($categories as $cat)
{
  $cat->getNode(); 
//SELECT * FROM category c WHERE ((c.lft > '1' AND c.rgt < '8') AND c.root_id = '1') ORDER BY c.lft asc
}

所以,总的来说,我得到的查询与类别一样多,这很糟糕。有什么想法吗?

【问题讨论】:

    标签: symfony1 doctrine nested-sets dql


    【解决方案1】:
    猜你喜欢
    • 1970-01-01
    • 2015-03-21
    • 2016-04-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-03
    • 1970-01-01
    相关资源
    最近更新 更多