[buddypress-dev] bpcontents 1.0 alpha 1 using MPTT
burt at ourcommoninterest.org
Tue May 26 02:20:33 GMT 2009
bpc uses a mechanism called Modifed Pre-Order Tree Traversal (MPTT) that
was specifically designed to track tree like structures in SQL tables. I
need to find out if that part of the core is working properly.
When you look at the properties for a node, in the class OCI_Node,
you'll notice two vars $this->lft and $this->rgt. These are MPTT specfic
vars that represent the parent/child relationships of all nodes in the
tree. . See these for info about MPTT:
A simple node insert or delete operation in the tree has a good chance
of changing 50% of the lft/rgt values in the entire tree.
Any sql operation that changes these values must:
1) lock the table
2) get the node and it's valid lft/rgt values
3) do the operation
4) unlock the tree
The only reliable property for a node in the tree is the $this->id which
is the record id in the table.
There is also a $this->parent_id in each node that represents the
immediate parent record id of that child node. There are times where
it's just more convenient to do things the Adjacency List way.
Code Is Freedom
More information about the buddypress-dev