From 93a737b4e1995934f7d31c25fd118cf3ab6eff2f Mon Sep 17 00:00:00 2001 From: romanb Date: Sat, 10 Feb 2007 18:07:05 +0000 Subject: [PATCH] Added missing multiple root support for Doctrine_Node_NestedSet::getParent() --- lib/Doctrine/Node/NestedSet.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/Doctrine/Node/NestedSet.php b/lib/Doctrine/Node/NestedSet.php index c2035a253..a33e0075c 100644 --- a/lib/Doctrine/Node/NestedSet.php +++ b/lib/Doctrine/Node/NestedSet.php @@ -196,10 +196,12 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int $q = $this->record->getTable()->createQuery(); $componentName = $this->record->getTable()->getComponentName(); - $parent = $q->where("$componentName.lft < ? AND $componentName.rgt > ?", array($this->getLeftValue(), $this->getRightValue())) - ->orderBy("$componentName.rgt asc") - ->execute() - ->getFirst(); + $q = $q->where("$componentName.lft < ? AND $componentName.rgt > ?", array($this->getLeftValue(), $this->getRightValue())) + ->orderBy("$componentName.rgt asc"); + $q = $this->record->getTable()->getTree()->returnQueryWithRootId($q, $this->getRootValue()); + + $parent = $q->execute()->getFirst(); + if(!$parent) $parent = $this->record->getTable()->create();