API16

JTable/checkIn: Difference between revisions

From Joomla! Documentation

Doxiki (talk | contribs)
New page: ===Description=== Method to check a row in if the necessary properties/fields exist. Checking a row in will allow other users the ability to edit the row. <span class="editsection" styl...
 
m preparing for archive only
 
(One intermediate revision by the same user not shown)
Line 2: Line 2:
Method to check a row in if the necessary properties/fields exist. Checking a row in will allow other users the ability to edit the row.
Method to check a row in if the necessary properties/fields exist. Checking a row in will allow other users the ability to edit the row.


<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JTable/checkIn|Edit Descripton]]<nowiki>]</nowiki>
</span>


{{Description:JTable/checkIn}}
 
 


===Syntax===
===Syntax===
Line 71: Line 69:
</source>
</source>


<span class="editsection" style="font-size:76%;">
 
<nowiki>[</nowiki>[[SeeAlso:JTable/checkIn|Edit See Also]]<nowiki>]</nowiki>
 
</span>
{{SeeAlso:JTable/checkIn}}


===Examples===
===Examples===
<CodeExamplesForm />
=== Code Examples ===
<dpl>
<dpl>
  noresultsheader=\n
  noresultsheader=\n
  category=checkIn
  category=checkIn
  category=JTable
  category=JTable
  category=CodeExample
  namespace=CodeExample
  category=MethodExample
  category=MethodExample
  include=*
  include=*
  format= ,,,
  format= ,,,
</dpl>
</dpl>

Latest revision as of 02:09, 25 March 2017

Description

Method to check a row in if the necessary properties/fields exist. Checking a row in will allow other users the ability to edit the row.



Syntax

checkIn($pk=null)
Parameter Name Default Value Description
$pk null An optional primary key value to check out. If not set the instance property value is used.

Returns

boolean True on success.

Defined in

libraries/joomla/database/table.php

Importing

jimport( 'joomla.database.table' );

Source Body

public function checkIn($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;
        }

        // Check the row in by primary key.
        $this->_db->setQuery(
                'UPDATE `'.$this->_tbl.'`' .
                ' SET `checked_out` = 0,' .
                '       `checked_out_time` = '.$this->_db->quote($this->_db->getNullDate()) .
                ' WHERE `'.$this->_tbl_key.'` = '.$this->_db->quote($pk)
        );
        $this->_db->query();

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

        // Set table values in the object.
        $this->checked_out = 0;
        $this->checked_out_time = '';

        return true;
}



Examples

Code Examples