From Joomla! Documentation

< API16:JTable
Revision as of 16:41, 22 March 2010 by Doxiki (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.


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.

[Edit Descripton]



getNextOrder($where= '')
Parameter Name Default Value Description
$where WHERE clause to use for selecting the MAX(ordering) for the table.


mixed Boolean false an failure or the next ordering value as an integer.

Defined in



jimport( 'joomla.database.table' );

Source Body

public function getNextOrder($where = '')
        // If there is no ordering field set an error and return false.
        if (!property_exists($this, 'ordering')) {
                $this->setError(get_class($this).' does not support ordering');
                return false;
        // Prepare the WHERE clause if set.
        $where = ($where) ? ' WHERE '.$where : '';
        // Get the largest ordering value for a given where clause.
                'SELECT MAX(ordering)' .
                ' FROM `'.$this->_tbl.'`' .
        $max = (int) $this->_db->loadResult();
        // Check for a database error.
        if ($this->_db->getErrorNum()) {
                return false;
        // Return the largest ordering value + 1.
        return ($max + 1);

[Edit See Also] SeeAlso:JTable/getNextOrder


<CodeExamplesForm />