1.5 Template Project

The Joomla! Documentation Working Group is running a project to develop detailed reference and tutorial material on Joomla! 1.5 templates.  There is a project page on the documentation wiki where you can see the work in progress and help us by contributing your knowledge.

Who's Online

We have 1 guest online

Help Site License

The Joomla! Help Site content is copyright © 2005 - 2008 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution NonCommercial ShareAlike 2.5. Some parts of this website may be subject to other licenses.
Home arrow Developer Manual arrow 11. API Reference arrow [WORKING] mosDBTable->checkout

[WORKING] mosDBTable->checkout PDF Print E-mail

Last reviewed: Not reviewed
phpDocumentor

mosDBTable->checkout

Generic check-out function. This method may be overriden/supplemented by the child class as required.

Sets the checked_out flag and sets the checked_out_time to the current date and time. The database table must contain a checked_out field otherwise this function will return false. If the check-out cannot be performed then this function returns false and an error message can be obtained by calling the mosDBTable->getError function.

Before calling this method you should first determine whether the record has been checked out by another user. From Joomla 1.0 onwards this can be done using the mosDBTable->isCheckedOut method.

See also the mosDBTable->checkin method.

Syntax

boolean checkout ( int $who [, int $id ] )

$who
The id of the person who is checking out this record.
$id
The primary key index for the current record. If null then the most recently used value for the primary key will be used. This parameter is optional and if omitted will default to null.

Examples

Example: In this example the database row (in table jos_categories) with id 1 is checked out by the current logged in user.

global $database, $my;
 
// Declare an instance of the mosCategory class.
$cat = new mosCategory( $database );
 
// Load record with primary key id 1.
$uid = 1;
if (!$cat->load( $uid )) {
  echo "Cannot load category record $uid: " . $database->stderr();
}
 
// Show some fields from this record.
echo "<br />";
echo "Title: $cat->title<br />";
echo "Description: $cat->description<br />";
echo "Checked out: $cat->checked_out<br />";
echo "Checked out time: $cat->checked_out_time<br />";
 
// Checkout the record.
echo "<br />";
if (!$my->id) {
  echo "You must be logged in to check out an item.<br />";
} else {
 
  echo "Checking out category record $uid<br />";
 
  // Check that the record is not already checked out by someone else.
  if ($cat->isCheckedOut( $my->id )) {
    echo "Cannot checkout record $uid as it is already checked out by another user.<br />";
 
  } else {
 
    // All clear so we can now checkout the record.
    if (!$cat->checkout( $my->id )) {
      echo "Cannot checkout record $uid: " . $cat->getError();
    } else {
      echo "<br />";
      $cat->load( $uid );
      echo "Checked out: $cat->checked_out<br />";
      echo "Checked out time: $cat->checked_out_time<br />";
    }
  }
}

Which would output something like this:

Title: Latest
Description: The latest news from the Joomla! Team
Checked out: 0
Checked out time: 0000-00-00 00:00:00
 
Checking out category record 1
 
Checked out: 62
Checked out time: 2005-10-28 16:47:56

Please report any errors on this page to the Developer Documentation Forum.

Last Updated ( Monday, 25 December 2006 )
 
< Prev   Next >