Skip to content
Derek Jones edited this page Jul 5, 2012 · 25 revisions

Information about SQL trees: http://dev.e-taller.net/dbtree/

=> a bit of inspiration...

Category:Models::3rd Party

Modified Preorder Tree Traversal (or Nested Sets) tree model

To install, just unzip the file into your app dir. (you can delete the manual folder if you want, it isn't needed, neither is the custom loader (can be handy though)).
Load the model with $this->load->model(’MPTtree’), and then set the table name with $this->MPTtree->set_table(’tablename’)

Check the comments in file or the accompanying html manual on how to use the model.

Download


File:MPTtree_0_1_6-fix.zip

Thread: http://codeigniter.com/forums/viewthread/74114/

A simple admin interface (supports moving, deleting and insertion of nodes (editing you have to implement yourselves)):
File:MPTtree_admin_0_1.zip

Author

Martin Wernstahl <m4rw3r at gmail dot com>

License

MPTtree is licensed under LGPL

Change Log

Version 0.1.6-fix

Release Date: March 27, 2008

Fixed error with call to db::get_where() in move_node() Corrected return values from move_node(), now it returns a normal array, just like insert_node() tree2array() now returns false if the root node cannot be found Added some debug messages Renamed MPTtree.php to mpttree.php to avoid include errors under linux Minor corrections in the manual

Version 0.1.6

Release Date: March 22, 2008

Added tree2array() Added get_descendants_wlevel() Added has_children() Added has_children() to ORM object Added command swith to get_descendants() to make it call get_descendants_wlevel() instead, thus returning a level column get_ORM() can now also accept a path (string or array doesn't matter) to the node which to load.

Version 0.1.5

Release Date: March 13, 2008

Introducing an ORM wrapper for MPTtree Added a MPTtreeIterator, to iterate over descendants in the tree Added a MPTtreeORMIterator, to iterate over descendants in the tree, returning ORM objects Added get_node_byid() Added an (optional) custom MY_Loader.php, to make it easier to have multiple instances at the same time (no need extending classes). Improved get_parent() Improved count_children(), not as much database traffic and counting is done in database Improved xpath(), more accurate (doesn't need xpath2() anymore) Changed the return values from the insert and move methods to return the new lft and rgt values instead of true. xpath() and xpath2() can now also accept an array as path (no need using separators)

Version 0.1.4

Release Date: February 26, 2008

Added a few methods to be used with Active Record, see Active Record helpers Added calls to db::protect_identifiers() in set_opts() and in set_table() Replaced the method xpath() with a much more efficient xpath variant. The old xpath() method have been renamed to path2(). HCG: Replaced use of transactions with locks

Version 0.1.2

Release Date: February 20, 2008

Added the method xpath() Remade set_opts() to accept an array with the parameters Added a sanitation of the data to update_node() and to the insert methods. This to prevent damage to the tree.

Version 0.1.1

Release Date: February 18, 2008

Added transaction support Added the method get_descendants_where() Added the method get_children_where() Changed algohrithm for get_children(), the new is almost twice as fast as the old one! Renamed some internal properties to address some conflicts with different CI libraries Changed name of get_decendants() to get_descendants(), a bad misspelling by me.

Version 0.1.0

Release Date: February 9, 2008

Initial Release

Thanks To:

Hamish Guthrie <hamish at prodigi dot ch> (Table locking)
Clone this wiki locally