Symfony 2 - querybuilder 嵌套树数组
Symfony 2 - querybuilder nested tree array
场景如下:
id parent_id search
1 null hello
2 1 hello/something
3 1 hello/new
4 null new
5 4 new/hello
然后我通过 querybuilder 搜索 "hello" 得到这个结果:
1 null hello
2 1 hello/something
3 1 hello/new
5 4 new/hello
5 4 new/hello
如果我只想获取子元素中的所有元素,如何通过 querybuilder 构建嵌套树,包括 "hello/something"?
如何使用symfony搭建数组?
假设您使用的是 Doctrine,请查看 tree extension in DoctrineExtensions
场景如下:
id parent_id search
1 null hello
2 1 hello/something
3 1 hello/new
4 null new
5 4 new/hello
然后我通过 querybuilder 搜索 "hello" 得到这个结果:
1 null hello
2 1 hello/something
3 1 hello/new
5 4 new/hello
5 4 new/hello
如果我只想获取子元素中的所有元素,如何通过 querybuilder 构建嵌套树,包括 "hello/something"?
如何使用symfony搭建数组?
假设您使用的是 Doctrine,请查看 tree extension in DoctrineExtensions