PHP 实现无限分类

附言 1  ·  6年前

PHP实现无限分类

《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 3

没有这么玩的
先去看看wiki上是咋定义Nested set model吧

6年前 评论
lmaster

@Insua 看了下 Nested set model 在查询上可能有飞快的感觉。
问题如下:

file

file
我想给 Suits 下在加一个 二股筋 (一种背心,英文实在是不知道怎么说),简称 Egj,这是该怎么做那?

file

SELECT
    Child.*
FROM
    tree AS Child,
    tree AS Parent
WHERE
    Child.depth = Parent.depth + 1
AND Parent.pid = 0

或者

SELECT
    Child.*
FROM
    tree AS Child,
    tree AS Parent
WHERE
    Child.depth = Parent.depth + 1
AND Child.`left` > Parent.`left`
AND Child.`right` < Parent.`right`
AND Parent.pid = 0

结果一样
file
Nested set model 这么做的优势在那里啊?

6年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!