写一个php class

yijiang 2008-05-10 12:32:31
Table below contains hierarchical data (tree):

id parent_id Node
1 0 Node 1
2 0 Node 2
3 1 Node 1.1
4 1 Node 1.2
5 2 Node 2.1

Task: write a class that will load the tree from the table.

Class API:

Methods Description
getChildNode(parent_node_id) Returns an array of child nodes given an id of a parent node (parent_node_id)
getBreadcrumbs(node_id) Returns an array of nodes, which make up a “path” to the node given a node_id
renderTree() Renders the tree

...全文
230 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧