1
0
mirror of synced 2025-01-18 22:41:43 +03:00

Added missing multiple root support to Doctrine_Node_NestedSet::getNextSibling()

and Doctrine_Node_NestedSet::getPrevSibling()
This commit is contained in:
romanb 2007-02-10 17:51:42 +00:00
parent e006ebb056
commit a0def4808f

View File

@ -79,7 +79,9 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
public function getPrevSibling()
{
$q = $this->record->getTable()->createQuery();
$result = $q->where('rgt = ?', $this->getLeftValue() - 1)->execute()->getFirst();
$q = $q->where('rgt = ?', $this->getLeftValue() - 1);
$q = $this->record->getTable()->getTree()->returnQueryWithRootId($q, $this->getRootValue());
$result = $q->execute()->getFirst();
if(!$result)
$result = $this->record->getTable()->create();
@ -95,7 +97,9 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
public function getNextSibling()
{
$q = $this->record->getTable()->createQuery();
$result = $q->where('lft = ?', $this->getRightValue() + 1)->execute()->getFirst();
$q = $q->where('lft = ?', $this->getRightValue() + 1);
$q = $this->record->getTable()->getTree()->returnQueryWithRootId($q, $this->getRootValue());
$result = $q->execute()->getFirst();
if(!$result)
$result = $this->record->getTable()->create();