SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 81 | Next

James Kennard

"Mastering Joomla! 1.5 Extension and Framework Development"


Hits
To increment the hits field we can use the hit() method. In this example we set the
buffer record ID and use the hit() method.
$table->set('id', $id);
$table->hit();
Alternatively we can specify the ID when we use the hit() method. If we choose to
do this, we must remember that the buffer ID will be updated to match the hit ID.
$table->hit($id);
Checking Out
Before we start checking out records, we first need to check if a record is already
checked out. Remember that when a record is checked out we should not allow any
other user to modify the record. We can use the isCheckOutMethod() to achieve
this. In this example, we test to see if any user, other than the current user, has
checked out the record:
The Database
[ 60 ]
$table->load($id);
$user =& JFactory::getUser();
if ($table->isCheckedOut($user->get('id')))
{
// handle record is already checked-out
}
Once we have determined a record isn't checked out, we can use the checkout()
method to check out the record. In this example, we check out the record to the
current user; this sets the checked_out field to the user's ID and the checked_out_
time field to the current time.


Pages:
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93