【问题标题】:Symfony 2 - querybuilder nested tree arraySymfony 2 - querybuilder 嵌套树数组
【发布时间】:2015-03-24 14:51:56
【问题描述】:

这里是场景:

   id  parent_id  search
   1   null       hello
   2   1          hello/something
   3   1          hello/new
   4   null       new
   5   4          new/hello

然后我通过 querybuilder 搜索“你好”这个结果:

   1   null       hello
   2   1          hello/something
   3   1          hello/new
   5   4          new/hello
   5   4          new/hello

如果我只想获取子元素中的所有元素,如何通过 querybuilder 构建嵌套树,包括“hello/something”?

如何使用 symfony 建立数组?

【问题讨论】:

    标签: symfony


    【解决方案1】:

    假设您正在使用 Doctrine,请查看 tree extension in DoctrineExtensions

    【讨论】:

    • 我不想使用 Doctrine,我知道这一点,但我正在使用 LIKE 语句。
    • 如果学说扩展不能用,那就把它弄成一个数组再看this answer
    猜你喜欢
    • 1970-01-01
    • 2018-06-04
    • 2017-06-14
    • 2013-06-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-07
    • 2013-03-25
    相关资源
    最近更新 更多