Gallery3:Developer Handbook:MPTT - Gallery Codex
Personal tools

Gallery3:Developer Handbook:MPTT

From Gallery Codex

Revision as of 14:20, 13 June 2011 by Ckdake (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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.