Hieratic Category Query |
[eluser]lightnb[/eluser]
Would it make sense then to have a root that isn't actually the root of the tree, but a logical device that exists for the sole purpose of tree integrity? In other words, a root node, manually inserted, that never actually gets displayed or used in the application for any reason?
[eluser]lightnb[/eluser]
So the demo/Library works if the root is left alone. But I'm still very confused as to how the library integrates with my existing application. For insertion: My controller has the name of the new node as a string, and the UID of the parent node as an int. The Controller then calls the "AddNewCategory" method of my model. Code: function AddNewCategory($NewCatName, $ParentCatID)
[eluser]esra[/eluser]
[quote author="lightnb" date="1205644714"]Would it make sense then to have a root that isn't actually the root of the tree, but a logical device that exists for the sole purpose of tree integrity? In other words, a root node, manually inserted, that never actually gets displayed or used in the application for any reason?[/quote] With nested sets, you need a parent root node as the basis of each hierarchy. All MPTT or MIPTT queries are based on the existence of a root node. However, this does not mean that a single table could not store multiple hierarchies, each with their own root. You could create a second table called trees and add a foreign key to the hierarchies table to associate hierarchies of nodes with different trees (roots). Then it's possible to clone (copy) an existing hierarchy and append it to another hierarchy (tree) with a different foreign key. In this case, you could think of the hierarchies table itself as a root of all hierarchies (trees) contained within that table. There are some other approaches to handling this based on the use of a level column, making it easier to copy and move branches of a tree about. http://www.phpriot.com/articles/nested-trees-1
[eluser]lightnb[/eluser]
I might be getting closer... I'm now getting: Quote:An Error Was Encountered and using this code in the controller: Code: $this->load->model('Nested_sets_model', 'cats'); It looks like the query isn't getting finished? |
Welcome Guest, Not a member yet? Register Sign In |