- It is the entrance of the Application.
- It requires NodeHandler.php and new object NodeHandler creates there.
- At the top of the code block the possible realization of the inserting and deleting of nodes is presented under comments.
- Inside
<!-- Tree structure -->
block of html there are$nodes->showTree()
and$nodes->showTree(3)
that provides representation of Nodes Tree in two modes:$nodes->showTree()
show the whole Tree of Nodes,$nodes->showTree(3)
show the part of Tree of Nodes limited by node with$id = 3
.
- This is the main stylesheet of the application.
- Provides connection to Database via singleton pattern.
- Parameters for connection stores in properties of the class DbConnector:
$host
for host name,$db_name
for name of the Database,$user
for login,$pass
for password.
- Main methods are:
getInstance()
for class DbConnector,getConnection()
for PDO Object.
- This file store class Model to perform the operations with DB.
- Main methods are:
getNodes()
to show show whole tree of nodes or its part,setNode()
to add new node to the tree,deleteNode()
to delete node from tree.
- This method gives the representation of nodes to page index.php.
- Main methods are:
showTree()
toecho
the whole tree of nodes or its part if parameter is provided,addNewNode()
to add now node to Database via Model.php to the root or specified level,deleteNode()
to delete node from Database via Model.php from the specified level or to delete the whole tree.
- This is the dump of the tables of my local
tree-structure
Database. - It is partly filled for example.
- Data stores via Nested Sets method.
- For example is provided a catalogue (of cars) in such hierarchy:
- vehicle
- Type (Motorcycle, Automobile)
- Brand (Audi, BMW, Ford)
- Model (A1, A2, Focus, etc.)
- Year (1999, 2003, etc.)
- Model (A1, A2, Focus, etc.)
- Brand (Audi, BMW, Ford)
- Type (Motorcycle, Automobile)
- All nodes are nested on correspond levels.
- New root level near
vehicle
can be added. For example,animal
with its own hierarchy of nodes, but bonded with near root node byright_key
andleft_key
.