/**
* Method to update order of table rows
*
* @param array $idArray id numbers of rows to be reordered.
* @param array $lftArray lft values of rows to be reordered.
*
* @return integer|boolean 1 + value of root rgt on success, false on failure.
*
* @since 1.7.0
* @throws \Exception on database error.
*/
public function saveorder($idArray = null, $lftArray = null)
{
try {
$query = $this->_db->getQuery(true);
// Validate arguments
if (\is_array($idArray) && \is_array($lftArray) && \count($idArray) == \count($lftArray)) {
for ($i = 0, $count = \count($idArray); $i < $count; $i++) {
// Do an update to change the lft values in the table for each id
$query->clear()->update($this->_tbl)->where($this->_tbl_key . ' = ' . (int) $idArray[$i])->set('lft = ' . (int) $lftArray[$i]);
$this->_db->setQuery($query)->execute();
if ($this->_debug) {
$this->_logtable();
}
}
return $this->rebuild();
} else {
return false;
}
} catch (\Exception $e) {
$this->_unlock();
throw $e;
}
}