Gallery3:Developer Handbook:MPTT - Gallery Codex
Personal tools

Gallery3:Developer Handbook:MPTT

From Gallery Codex

Modified Preorder Tree Traversal (MPTT)

For storing hierarchical data in the database, Gallery 3 uses the ORM_MPTT subclass to ORM which implements Modified Preorder Tree Traversal. This is a technique for keeping track of parent/child relationships for a tree of data which allows for extremely efficient read access. There’s a great description of the concept and how it works on that you should read if you plan on working with MPTT. The ORM_MPTT class does the bulk of the work for you. Using it is very simple, simply add left_ptr, right_ptr, parent_id, and level integer columns to your database table and then have your model extend the ORM_MPTT class instead of ORM.