写一个php class
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