API16:JTable/getNextOrder
From Joomla! Documentation
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.
Contents |
Description
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.
Description:JTable/getNextOrder
Syntax
getNextOrder($where= '')
| Parameter Name | Default Value | Description |
|---|---|---|
| $where | WHERE clause to use for selecting the MAX(ordering) for the table. |
Returns
mixed Boolean false an failure or the next ordering value as an integer.
Defined in
libraries/joomla/database/table.php
Importing
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. $this->_db->setQuery( 'SELECT MAX(ordering)' . ' FROM `'.$this->_tbl.'`' . $where ); $max = (int) $this->_db->loadResult(); // Check for a database error. if ($this->_db->getErrorNum()) { $this->setError($this->_db->getErrorMsg()); return false; } // Return the largest ordering value + 1. return ($max + 1); }
[Edit See Also] SeeAlso:JTable/getNextOrder
Examples
<CodeExamplesForm />
