PHP - Create a nested array from MySQL data

扶醉桌前 提交于 2019-12-05 23:13:39

There is a very good description of managing hierarchical data in mysql here: managing hierarchical data Here is another good example of building nested arrays: building nested arrays

You may think about using the Nested Set model. If you are going to query stuff mutch it is better than the adjacency model you are using right now.

Hope that helps.

You won't have hierarchical data from "plain" SQL dataset, but you can write a function that will do that recursively. I can't provide code at the moment, but you probably get the idea.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!