MPTtree, Hieararchical trees in a database table |
[eluser]TheLoops[/eluser]
I myself have have written (or rather adapted) a nested tree model for CI. I actually just turned this class to a CI model that uses CI's native Active Record. But unfortunately it does not have any useful editing functionality implemented. Hence I'll most likely have to drop it in favor of MPTree. Nevertheless there are some features in my model wich I'd like to see in MPTree. Quote:(bool) isDescendantOf(…) Furthermore I'm curious why you did not add a parent_id and a nlevel field to MPTree. Using such fields would make many of MPTree's so more simple. Both: to understand for the user and also to maintenance. Just take thes simple query as example: MPTree's approach WITHOUT a parent_id field: Code: function count_children($lft,$rgt){ Versus an approach WITH a parent_id field: Code: function count_children($lft,$rgt,$id = NULL){ Or another MPTree's approach WITHOUT a parent_id field: Code: function AR_from_children_of($lft,$rgt){ Versus an approach with parent_id field: Code: function AR_from_children_of($lft,$rgt,$id = NULL){ I highly recommend to use a parent_id field. It just makes things much easier. And the MySQL queries should also get a significant performance boost in some cases. |
Welcome Guest, Not a member yet? Register Sign In |