开发者

nested set, how to set left and right value with php&mysql

when i search on the internet about nest开发者_如何学Pythoned set, everyone assume i have already left and right values. but i dont have (; i have id, name, parent_id as column. how can i find left and right values?

i guess, i must use recursive alg. but not design it yet.

thanks a lot, erman


Your current model is called an adjacency list. In order to get left and right values, you'll need to perform a push down stack algorithm to convert your model to a nested set.

Here's an example: http://data.bangtech.com/sql/nested_set_treeview.htm

You can also search the web for other conversions from adjacency list to nested set.

Hope that helps!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜