diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2008-12-04 01:12:44 +0000 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2008-12-04 01:12:44 +0000 |
commit | 5c095cbd787bf71e30658536aafdbf8ea837aa1f (patch) | |
tree | 670301aa58fca86c16d18f4ea5615fb70e214d73 /core/libraries | |
parent | 9ae6acdc0ab3f40fa6267161d733e79d4424eb0b (diff) |
Add unit tests to test growing and contracting the left and right pointers
Added a delete method to ORM_MPTT that contracts the tree when an item is deleted
Diffstat (limited to 'core/libraries')
-rw-r--r-- | core/libraries/ORM_MPTT.php | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/core/libraries/ORM_MPTT.php b/core/libraries/ORM_MPTT.php index d7e8d7b7..2cdc617d 100644 --- a/core/libraries/ORM_MPTT.php +++ b/core/libraries/ORM_MPTT.php @@ -73,6 +73,14 @@ class ORM_MPTT_Core extends ORM { } /** + * Deleted this node and adjust the left and right pointers + */ + public function delete() { + parent::delete(); + $this->_grow(-1); + } + + /** * Return the parent of this node * * @return ORM @@ -194,7 +202,7 @@ class ORM_MPTT_Core extends ORM { * * @param integer $count the number of new nodes to add */ - private function _grow($count=1) { + public function _grow($count=1) { $size = $count * 2; $this->db->query( "UPDATE `{$this->table_name}` SET `left` = `left` + $size WHERE `left` >= {$this->right}"); |