From 18cf2887cfa759f7b6d64e819fc1eeecd3564a41 Mon Sep 17 00:00:00 2001 From: romanb Date: Sat, 10 Feb 2007 17:58:29 +0000 Subject: [PATCH] Added missing multiple root support for Doctrine_Node_NestedSet::getFirstChild() and Doctrine_Node_NestedSet::getLastChild() --- lib/Doctrine/Node/NestedSet.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/Doctrine/Node/NestedSet.php b/lib/Doctrine/Node/NestedSet.php index 735d1bc21..c2035a253 100644 --- a/lib/Doctrine/Node/NestedSet.php +++ b/lib/Doctrine/Node/NestedSet.php @@ -138,7 +138,9 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int public function getFirstChild() { $q = $this->record->getTable()->createQuery(); - $result = $q->where('lft = ?', $this->getLeftValue() + 1)->execute()->getFirst(); + $q = $q->where('lft = ?', $this->getLeftValue() + 1); + $q = $this->record->getTable()->getTree()->returnQueryWithRootId($q, $this->getRootValue()); + $result = $q->execute()->getFirst(); if(!$result) $result = $this->record->getTable()->create(); @@ -154,7 +156,9 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int public function getLastChild() { $q = $this->record->getTable()->createQuery(); - $result = $q->where('rgt = ?', $this->getRightValue() - 1)->execute()->getFirst(); + $q = $q->where('rgt = ?', $this->getRightValue() - 1); + $q = $this->record->getTable()->getTree()->returnQueryWithRootId($q, $this->getRootValue()); + $result = $q->execute()->getFirst(); if(!$result) $result = $this->record->getTable()->create();