| [WORKING] mosDBTable->checkout |
|
Last reviewed: Not reviewed mosDBTable->checkoutGeneric 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. Syntaxboolean checkout ( int $who [, int $id ] )
ExamplesExample: 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 ) |