From Joomla! Documentation

< API16:JTable

The "API16" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.


Method to check a row out if the necessary properties/fields exist. To prevent race conditions while editing rows in a database, a row can be checked out if the fields 'checked_out' and 'checked_out_time' are available. While a row is checked out, any attempt to store the row by a user other than the one who checked the row out should be held until the row is checked in again.


checkOut($userId, $pk=null)
Parameter Name Default Value Description
$userId The Id of the user checking out the row.
$pk null An optional primary key value to check out. If not set the instance property value is used.


boolean True on success.

Defined in



jimport( 'joomla.database.table' );

Source Body

public function checkOut($userId, $pk = null)
        // If there is no checked_out or checked_out_time field, just return true.
        if (!property_exists($this, 'checked_out') || !property_exists($this, 'checked_out_time')) {
                return true;

        // Initialise variables.
        $k = $this->_tbl_key;
        $pk = (is_null($pk)) ? $this->$k : $pk;

        // If no primary key is given, return false.
        if ($pk === null) {
                return false;

        // Get the current time in MySQL format.
        $time = JFactory::getDate()->toMysql();

        // Check the row out by primary key.
                'UPDATE `'.$this->_tbl.'`' .
                ' SET `checked_out` = '.(int) $userId.',' .
                '       `checked_out_time` = '.$this->_db->quote($time) .
                ' WHERE `'.$this->_tbl_key.'` = '.$this->_db->quote($pk)

        // Check for a database error.
        if ($this->_db->getErrorNum()) {
                return false;

        // Set table values in the object.
        $this->checked_out = (int) $userId;
        $this->checked_out_time = $time;

        return true;


Code Examples