开发者

Hierarchical file-system application Schema problem?

I am creating an web application in which users can upload documents, crea开发者_运维问答te folders (just like any file explorer) problem Is how should I translate this Hierarchical structure into Mysql database flat structure, how should I creat a tree view from database? Backend (php,mysql,linux) Frontend (flex) thx


The simplest solution is to create your table which describe your files hierarchy like this

item_id | name/descriptio/other rows you need  | parent_item_id

Later when you will build the xml representation with complete and nice hierarchy, you will start from root directory, which will have parent_item_id = 0 (or null), and item_id = 1, this will be your first current_item_id. You add it as xml node to your xml. Than you will start recursively select items which have parent_item_id=current_item_id, and add them as a child nodes to current xml node.

All hard work, recursion will make for you.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜