通过路径遍历物化视图

时间:2015-07-28 03:20:45

标签: php sql postgresql

我使用此查询得到如下所示的数组:

  SELECT id, person_id, description, path FROM comment WHERE path <@ '0001' ORDER by path

我的问题是我如何使用将输出显示为线程?我是否检查前四个数字并增加以查看它们是否处于同一水平或是否存在我无法理解的内容?

[0] =&gt; Array
    (
        [id] =&gt; 1
        [person_id] =&gt; 1
        [description] =&gt; a75e62536ca2687ae5817acb739e61f3
        [path] =&gt; 0001
    )

[1] =&gt; Array
    (
        [id] =&gt; 2
        [person_id] =&gt; 2
        [description] =&gt; 010242f78cd5d41abb16a8ba488957a1
        [path] =&gt; 0001.0001.0001
    )

[2] =&gt; Array
    (
        [id] =&gt; 3
        [person_id] =&gt; 2
        [description] =&gt; cdde38b2b13ee808ce5423cdf8d14bab
        [path] =&gt; 0001.0001.0001.0001
    )

[3] =&gt; Array
    (
        [id] =&gt; 4
        [person_id] =&gt; 1
        [description] =&gt; 6b837ce73896fbd080bd0b93837ad537
        [path] =&gt; 0001.0001.0001.0002
    )

[4] =&gt; Array
    (
        [id] =&gt; 5
        [person_id] =&gt; 5
        [description] =&gt; e5694a273ed95d36934cff48cd8fb12a
        [path] =&gt; 0001.0001.0001.0003
    )

[5] =&gt; Array
    (
        [id] =&gt; 6
        [person_id] =&gt; 6
        [description] =&gt; 15b2ad371934352c0b16c5c1585f3d7d
        [path] =&gt; 0001.0002
    )

[6] =&gt; Array
    (
        [id] =&gt; 7
        [person_id] =&gt; 6
        [description] =&gt; 2d1595f0c4ec527c601f404c7a272407
        [path] =&gt; 0001.0002.0001
    )

[7] =&gt; Array
    (
        [id] =&gt; 8
        [person_id] =&gt; 6
        [description] =&gt; 8286c3bbe511d866e4e2ef4321a429d7
        [path] =&gt; 0001.0003
    )

[8] =&gt; Array
    (
        [id] =&gt; 9
        [person_id] =&gt; 8
        [description] =&gt; dc455dd484220176d1d2198f84bdbc90
        [path] =&gt; 0001.0003.0001
    )

[9] =&gt; Array
    (
        [id] =&gt; 10
        [person_id] =&gt; 9
        [description] =&gt; b8a8f41b224f900f6f5de0e591ba13b8
        [path] =&gt; 0001.0003.0002
    )

[10] =&gt; Array
    (
        [id] =&gt; 11
        [person_id] =&gt; 11
        [description] =&gt; ef132c4663961ff09ca61f40eec72697
        [path] =&gt; 0001.0003.0002.0001
    )

0 个答案:

没有答案