/**
* Method to move a row in the ordering sequence of a group of rows defined by an SQL WHERE clause.
* Negative numbers move the row up in the sequence and positive numbers move it down.
*
* @param integer $delta The direction and magnitude to move the row in the ordering sequence.
* @param string $where WHERE clause to use for limiting the selection of rows to compact the
* ordering values.
*
* @return mixed Boolean true on success.
*
* @since 1.7.0
*/
public function move($delta, $where = '')
{
$k = $this->_tbl_key;
$pk = $this->{$k};
$query = $this->_db->getQuery(true)->select($k)->from($this->_tbl)->where('parent_id = ' . $this->parent_id);
if ($where) {
$query->where($where);
}
if ($delta > 0) {
$query->where('rgt > ' . $this->rgt)->order('rgt ASC');
$position = 'after';
} else {
$query->where('lft < ' . $this->lft)->order('lft DESC');
$position = 'before';
}
$this->_db->setQuery($query);
$referenceId = $this->_db->loadResult();
if ($referenceId) {
return $this->moveByReference($referenceId, $position, $pk);
} else {
return false;
}
}