Commit c9dafc24 authored by Jonathan.Wage's avatar Jonathan.Wage

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

parent 22cdbd74
...@@ -80,7 +80,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int ...@@ -80,7 +80,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
public function getPrevSibling() public function getPrevSibling()
{ {
$q = $this->_tree->getBaseQuery(); $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()); $q = $this->_tree->returnQueryWithRootId($q, $this->getRootValue());
$result = $q->execute(); $result = $q->execute();
...@@ -105,7 +105,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int ...@@ -105,7 +105,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
public function getNextSibling() public function getNextSibling()
{ {
$q = $this->_tree->getBaseQuery(); $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()); $q = $this->_tree->returnQueryWithRootId($q, $this->getRootValue());
$result = $q->execute(); $result = $q->execute();
...@@ -150,7 +150,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int ...@@ -150,7 +150,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
public function getFirstChild() public function getFirstChild()
{ {
$q = $this->_tree->getBaseQuery(); $q = $this->_tree->getBaseQuery();
$q->where('base.lft = ?', $this->getLeftValue() + 1); $q->addWhere('base.lft = ?', $this->getLeftValue() + 1);
$this->_tree->returnQueryWithRootId($q, $this->getRootValue()); $this->_tree->returnQueryWithRootId($q, $this->getRootValue());
$result = $q->execute(); $result = $q->execute();
...@@ -175,7 +175,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int ...@@ -175,7 +175,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
public function getLastChild() public function getLastChild()
{ {
$q = $this->_tree->getBaseQuery(); $q = $this->_tree->getBaseQuery();
$q->where('base.rgt = ?', $this->getRightValue() - 1); $q->addWhere('base.rgt = ?', $this->getRightValue() - 1);
$this->_tree->returnQueryWithRootId($q, $this->getRootValue()); $this->_tree->returnQueryWithRootId($q, $this->getRootValue());
$result = $q->execute(); $result = $q->execute();
...@@ -215,9 +215,9 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int ...@@ -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')); $params = array($this->record->get('lft'), $this->record->get('rgt'));
if ($includeNode) { 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 { } 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) { if ($depth !== null) {
...@@ -242,8 +242,8 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int ...@@ -242,8 +242,8 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
public function getParent() public function getParent()
{ {
$q = $this->_tree->getBaseQuery(); $q = $this->_tree->getBaseQuery();
$q->where("base.lft < ? AND base.rgt > ?", array($this->getLeftValue(), $this->getRightValue())) $q->addWhere("base.lft < ? AND base.rgt > ?", array($this->getLeftValue(), $this->getRightValue()))
->orderBy("base.rgt asc"); ->addOrderBy("base.rgt asc");
$q = $this->_tree->returnQueryWithRootId($q, $this->getRootValue()); $q = $this->_tree->returnQueryWithRootId($q, $this->getRootValue());
$result = $q->execute(); $result = $q->execute();
...@@ -270,8 +270,8 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int ...@@ -270,8 +270,8 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
public function getAncestors($depth = null) public function getAncestors($depth = null)
{ {
$q = $this->_tree->getBaseQuery(); $q = $this->_tree->getBaseQuery();
$q->where("base.lft < ? AND base.rgt > ?", array($this->getLeftValue(), $this->getRightValue())) $q->addWhere("base.lft < ? AND base.rgt > ?", array($this->getLeftValue(), $this->getRightValue()))
->orderBy("base.lft asc"); ->addOrderBy("base.lft asc");
if ($depth !== null) { if ($depth !== null) {
$q->addWhere("base.level >= ?", $this->record['level'] - $depth); $q->addWhere("base.level >= ?", $this->record['level'] - $depth);
} }
...@@ -765,7 +765,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int ...@@ -765,7 +765,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
$componentName = $this->record->getTable()->getComponentName(); $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); $q = $this->record->getTable()->getTree()->returnQueryWithRootId($q, $oldRoot);
...@@ -950,7 +950,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int ...@@ -950,7 +950,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
if (!isset($this->record['level'])) { if (!isset($this->record['level'])) {
$componentName = $this->record->getTable()->getComponentName(); $componentName = $this->record->getTable()->getComponentName();
$q = $this->_tree->getBaseQuery(); $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()); $q = $this->_tree->returnQueryWithRootId($q, $this->getRootValue());
......
...@@ -109,7 +109,7 @@ class Doctrine_Tree_NestedSet extends Doctrine_Tree implements Doctrine_Tree_Int ...@@ -109,7 +109,7 @@ class Doctrine_Tree_NestedSet extends Doctrine_Tree implements Doctrine_Tree_Int
public function fetchRoot($rootId = 1) public function fetchRoot($rootId = 1)
{ {
$q = $this->getBaseQuery(); $q = $this->getBaseQuery();
$q = $q->where('base.lft = ?', 1); $q = $q->addWhere('base.lft = ?', 1);
// if tree has many roots, then specify root id // if tree has many roots, then specify root id
$q = $this->returnQueryWithRootId($q, $rootId); $q = $this->returnQueryWithRootId($q, $rootId);
...@@ -149,9 +149,9 @@ class Doctrine_Tree_NestedSet extends Doctrine_Tree implements Doctrine_Tree_Int ...@@ -149,9 +149,9 @@ class Doctrine_Tree_NestedSet extends Doctrine_Tree implements Doctrine_Tree_Int
// if tree has many roots, then specify root id // if tree has many roots, then specify root id
$rootId = isset($options['root_id']) ? $options['root_id'] : '1'; $rootId = isset($options['root_id']) ? $options['root_id'] : '1';
if (is_array($rootId)) { if (is_array($rootId)) {
$q->orderBy("base." . $this->getAttribute('rootColumnName') . ", base.lft ASC"); $q->addOrderBy("base." . $this->getAttribute('rootColumnName') . ", base.lft ASC");
} else { } else {
$q->orderBy("base.lft ASC"); $q->addOrderBy("base.lft ASC");
} }
$q = $this->returnQueryWithRootId($q, $rootId); $q = $this->returnQueryWithRootId($q, $rootId);
...@@ -183,7 +183,7 @@ class Doctrine_Tree_NestedSet extends Doctrine_Tree implements Doctrine_Tree_Int ...@@ -183,7 +183,7 @@ class Doctrine_Tree_NestedSet extends Doctrine_Tree implements Doctrine_Tree_Int
$q = $this->getBaseQuery(); $q = $this->getBaseQuery();
$params = array($record->get('lft'), $record->get('rgt')); $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()); $q = $this->returnQueryWithRootId($q, $record->getNode()->getRootValue());
return $q->execute(); return $q->execute();
} }
...@@ -197,7 +197,7 @@ class Doctrine_Tree_NestedSet extends Doctrine_Tree implements Doctrine_Tree_Int ...@@ -197,7 +197,7 @@ class Doctrine_Tree_NestedSet extends Doctrine_Tree implements Doctrine_Tree_Int
public function fetchRoots() public function fetchRoots()
{ {
$q = $this->getBaseQuery(); $q = $this->getBaseQuery();
$q = $q->where('base.lft = ?', 1); $q = $q->addWhere('base.lft = ?', 1);
return $q->execute(); return $q->execute();
} }
......
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