public function getNextOrder($where = '')
	{
		// If there is no ordering field set an error and return false.
		if (!property_exists($this, 'ordering'))
		{
			$e = new Exception(Lang::txt('JLIB_DATABASE_ERROR_CLASS_DOES_NOT_SUPPORT_ORDERING', get_class($this)));
			$this->setError($e);
			return false;
		}

		// Get the largest ordering value for a given where clause.
		$query = $this->_db->getQuery();
		$query->select('MAX(ordering)');
		$query->from($this->_tbl);

		if ($where)
		{
			$query->whereRaw($where);
		}

		$this->_db->setQuery($query->toString());
		$max = (int) $this->_db->loadResult();

		// Check for a database error.
		if ($this->_db->getErrorNum())
		{
			$e = new Exception(Lang::txt('JLIB_DATABASE_ERROR_GET_NEXT_ORDER_FAILED', get_class($this), $this->_db->getErrorMsg()));
			$this->setError($e);

			return false;
		}

		// Return the largest ordering value + 1.
		return ($max + 1);
	}
public function getNextOrder($where = '')
	{
		// If there is no ordering field set an error and return false.
		if (!property_exists($this, 'ordering'))
		{
			$e = new Exception(Lang::txt('JLIB_DATABASE_ERROR_CLASS_DOES_NOT_SUPPORT_ORDERING', get_class($this)));
			$this->setError($e);
			return false;
		}

		// Get the largest ordering value for a given where clause.
		$query = $this->_db->getQuery();
		$query->select('MAX(ordering)');
		$query->from($this->_tbl);

		if ($where)
		{
			$query->whereRaw($where);
		}

		$this->_db->setQuery($query->toString());
		$max = (int) $this->_db->loadResult();

		// Check for a database error.
		if ($this->_db->getErrorNum())
		{
			$e = new Exception(Lang::txt('JLIB_DATABASE_ERROR_GET_NEXT_ORDER_FAILED', get_class($this), $this->_db->getErrorMsg()));
			$this->setError($e);

			return false;
		}

		// Return the largest ordering value + 1.
		return ($max + 1);
	}
public function getNextOrder ( $ where = '' ) { // If there is no ordering field set an error and return false. if ( ! property_exists ( $ this , 'ordering' ) ) { $ e = new Exception ( Lang :: txt ( 'JLIB_DATABASE_ERROR_CLASS_DOES_NOT_SUPPORT_ORDERING' , get_class ( $ this ) ) ) ; $ this -> setError ( $ e ) ; return false ; } // Get the largest ordering value for a given where clause. $ query = $ this -> _db -> getQuery ( ) ; $ query -> select ( 'MAX(ordering)' ) ; $ query -> from ( $ this -> _tbl ) ; if ( $ where ) { $ query -> whereRaw ( $ where ) ; } $ this -> _db -> setQuery ( $ query -> toString ( ) ) ; $ max = ( int ) $ this -> _db -> loadResult ( ) ; // Check for a database error. if ( $ this -> _db -> getErrorNum ( ) ) { $ e = new Exception ( Lang :: txt ( 'JLIB_DATABASE_ERROR_GET_NEXT_ORDER_FAILED' , get_class ( $ this ) , $ this -> _db -> getErrorMsg ( ) ) ) ; $ this -> setError ( $ e ) ; return false ; } // Return the largest ordering value + 1. return ( $ max + 1 ) ; }
Method to get the next ordering value for a group of rows defined by an SQL WHERE clause.
This is useful for placing a new item last in a group of items in the table.

@param   string  $where  WHERE clause to use for selecting the MAX(ordering) for the table.
@return  mixed   Boolean false an failure or the next ordering value as an integer.
@since   2.1.12
Method to get the next ordering value for a group of rows defined by an SQL WHERE clause . This is useful for placing a new item last in a group of items in the table .