Commit 18cf2887 authored by romanb's avatar romanb

Added missing multiple root support for Doctrine_Node_NestedSet::getFirstChild() and

Doctrine_Node_NestedSet::getLastChild()
parent a0def480
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment