Concept
php Infinite Classification Principle A vivid metaphor is like a tree. This tree has its own roots, then trunk, and branches. From the stem to the leaves, the further forward, the denser it becomes. This is the same as classification. The further you go down, the more columns there are. Just like the WINDOWS operating system pre-installed on the PCs you use, you can try it. Try creating a new folder in a folder and then in this new folder, create a new one, and keep going. You can understand what infinite level is.
Principle
##First we assume that there is such a Three-level classification, news → PHP news → PHP6.0 is out. If we want to find the news "PHP6.0 is out", we first click on the news, and then click on the PHP news
to find it out. That is, we can search down level by level through the grandfather class. In turn, as long as weknow the parent class of a subclass, we can find it. In this way, when designing the database, we can set up an additional field of parent class ID to achieve unlimited classification. The parent class ID in the database is particularly important. Next, we will use the recursive method and iteration This method can complete the production of infinite classification. For a deeper understanding, we can use the metaphor of a family tree and a descendant tree.Family tree
is one of the manifestations of Infinitus classification, and the other isdescendant tree.The difference can also be seen from the Chinese meaning.Family trees are now popular in many places. How to build a family tree is to find an ancestor for yourself, and search for it from generation to generation, forming a system. What is compiled in this way is called a family tree. The family tree is similar.Start from a node and search upward for its parent node, and then search for the parent node of the parent node until it cannot be found. According to this search, a tree-like structure formed is called a family tree.
The descendant tree is the opposite. The descendant tree is similar to the genetic diagram in the biology book.Start from a node to find its child nodes, then look for the child nodes of the child node, until you find complete. The tree structure formed in this way is called a descendant tree.
Recursive flow chart
##Iterative flow chart
##Related articles:php Recursive implementation of infinite-level classification trees
phpUse recursive method to achieve infinite-level classification
phpInfinite-level classification implementation method analysis