求一个php的算法实现,实现如下:
将一个形如表1的树以表2的形式存储在一张数据库表中,现在希望删除一个子树(例如想删除red子树)该怎么做呢?
food
|--fruit
|----green
|------pear
|----red
|------cherry
|------apple
|----yellow
|------banana
|--meat
|----mutton
|----beef
|----pork
(表1)
id parent title
1 food
2 food fruit
3 fruit green
4 green pear
5 fruit red
6 red cherry
7 fruit yellow
8 yellow banana
9 food meat
10 meat mutton
11 meat beef
12 meat pork
13 red apple
(表2)
------解决方案--------------------
递归
