1
0
mirror of synced 2024-12-14 07:06:04 +03:00

Changed where() and orderBy() to addWhere() and addOrderBy()

This commit is contained in:
Jonathan.Wage 2007-07-12 15:41:26 +00:00
parent 22cdbd74c4
commit c9dafc24aa
2 changed files with 17 additions and 17 deletions

View File

@ -80,7 +80,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
public function getPrevSibling()
{
$q = $this->_tree->getBaseQuery();
$q = $q->where('base.rgt = ?', $this->getLeftValue() - 1);
$q = $q->addWhere('base.rgt = ?', $this->getLeftValue() - 1);
$q = $this->_tree->returnQueryWithRootId($q, $this->getRootValue());
$result = $q->execute();
@ -105,7 +105,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
public function getNextSibling()
{
$q = $this->_tree->getBaseQuery();
$q = $q->where('base.lft = ?', $this->getRightValue() + 1);
$q = $q->addWhere('base.lft = ?', $this->getRightValue() + 1);
$q = $this->_tree->returnQueryWithRootId($q, $this->getRootValue());
$result = $q->execute();
@ -150,7 +150,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
public function getFirstChild()
{
$q = $this->_tree->getBaseQuery();
$q->where('base.lft = ?', $this->getLeftValue() + 1);
$q->addWhere('base.lft = ?', $this->getLeftValue() + 1);
$this->_tree->returnQueryWithRootId($q, $this->getRootValue());
$result = $q->execute();
@ -175,7 +175,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
public function getLastChild()
{
$q = $this->_tree->getBaseQuery();
$q->where('base.rgt = ?', $this->getRightValue() - 1);
$q->addWhere('base.rgt = ?', $this->getRightValue() - 1);
$this->_tree->returnQueryWithRootId($q, $this->getRootValue());
$result = $q->execute();
@ -215,9 +215,9 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
$params = array($this->record->get('lft'), $this->record->get('rgt'));
if ($includeNode) {
$q->where("base.lft >= ? AND base.rgt <= ?", $params)->orderBy("base.lft asc");
$q->addWhere("base.lft >= ? AND base.rgt <= ?", $params)->addOrderBy("base.lft asc");
} else {
$q->where("base.lft > ? AND base.rgt < ?", $params)->orderBy("base.lft asc");
$q->addWhere("base.lft > ? AND base.rgt < ?", $params)->addOrderBy("base.lft asc");
}
if ($depth !== null) {
@ -242,8 +242,8 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
public function getParent()
{
$q = $this->_tree->getBaseQuery();
$q->where("base.lft < ? AND base.rgt > ?", array($this->getLeftValue(), $this->getRightValue()))
->orderBy("base.rgt asc");
$q->addWhere("base.lft < ? AND base.rgt > ?", array($this->getLeftValue(), $this->getRightValue()))
->addOrderBy("base.rgt asc");
$q = $this->_tree->returnQueryWithRootId($q, $this->getRootValue());
$result = $q->execute();
@ -270,8 +270,8 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
public function getAncestors($depth = null)
{
$q = $this->_tree->getBaseQuery();
$q->where("base.lft < ? AND base.rgt > ?", array($this->getLeftValue(), $this->getRightValue()))
->orderBy("base.lft asc");
$q->addWhere("base.lft < ? AND base.rgt > ?", array($this->getLeftValue(), $this->getRightValue()))
->addOrderBy("base.lft asc");
if ($depth !== null) {
$q->addWhere("base.level >= ?", $this->record['level'] - $depth);
}
@ -765,7 +765,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
$componentName = $this->record->getTable()->getComponentName();
$q = $q->where('base.lft >= ? AND base.rgt <= ?', array($this->getLeftValue(), $this->getRightValue()));
$q = $q->addWhere('base.lft >= ? AND base.rgt <= ?', array($this->getLeftValue(), $this->getRightValue()));
$q = $this->record->getTable()->getTree()->returnQueryWithRootId($q, $oldRoot);
@ -950,7 +950,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
if (!isset($this->record['level'])) {
$componentName = $this->record->getTable()->getComponentName();
$q = $this->_tree->getBaseQuery();
$q = $q->where('base.lft < ? AND base.rgt > ?', array($this->getLeftValue(), $this->getRightValue()));
$q = $q->addWhere('base.lft < ? AND base.rgt > ?', array($this->getLeftValue(), $this->getRightValue()));
$q = $this->_tree->returnQueryWithRootId($q, $this->getRootValue());

View File

@ -109,7 +109,7 @@ class Doctrine_Tree_NestedSet extends Doctrine_Tree implements Doctrine_Tree_Int
public function fetchRoot($rootId = 1)
{
$q = $this->getBaseQuery();
$q = $q->where('base.lft = ?', 1);
$q = $q->addWhere('base.lft = ?', 1);
// if tree has many roots, then specify root id
$q = $this->returnQueryWithRootId($q, $rootId);
@ -149,9 +149,9 @@ class Doctrine_Tree_NestedSet extends Doctrine_Tree implements Doctrine_Tree_Int
// if tree has many roots, then specify root id
$rootId = isset($options['root_id']) ? $options['root_id'] : '1';
if (is_array($rootId)) {
$q->orderBy("base." . $this->getAttribute('rootColumnName') . ", base.lft ASC");
$q->addOrderBy("base." . $this->getAttribute('rootColumnName') . ", base.lft ASC");
} else {
$q->orderBy("base.lft ASC");
$q->addOrderBy("base.lft ASC");
}
$q = $this->returnQueryWithRootId($q, $rootId);
@ -183,7 +183,7 @@ class Doctrine_Tree_NestedSet extends Doctrine_Tree implements Doctrine_Tree_Int
$q = $this->getBaseQuery();
$params = array($record->get('lft'), $record->get('rgt'));
$q->where("base.lft >= ? AND base.rgt <= ?", $params)->orderBy("base.lft asc");
$q->addWhere("base.lft >= ? AND base.rgt <= ?", $params)->addOrderBy("base.lft asc");
$q = $this->returnQueryWithRootId($q, $record->getNode()->getRootValue());
return $q->execute();
}
@ -197,7 +197,7 @@ class Doctrine_Tree_NestedSet extends Doctrine_Tree implements Doctrine_Tree_Int
public function fetchRoots()
{
$q = $this->getBaseQuery();
$q = $q->where('base.lft = ?', 1);
$q = $q->addWhere('base.lft = ?', 1);
return $q->execute();
}