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 77 | Next

James Kennard

"Mastering Joomla! 1.5 Extension and Framework Development"

This example demonstrates how we can
implement this.
if ($table->load($id))
{
// handle failed load
// use $table->getError() for an explanation
}
Chapter 3
[ 57 ]
else
{
$table->setVar('content', JRequest::getString('content'));
if ($table->check())
{
if (!$table->store(true))
{
// handle failed update
// use $table->getError() for an explanation
}
}
else
{
// handle invalid input
// use $table->getError() for an explanation
}
}
The last action that will occur in any record's life is deletion. Deleting a record using
JTable subclasses is very easy. This example shows how we delete a record.
if (!$table->delete($id))
{
// handle failed delete
}
If we don't pass an ID to the delete() method, the ID in the buffer will be used. It is
important to bear in mind that if you do pass an ID the buffer ID will be updated.
If we are deleting a record that has relationships with other tables, we can check
for dependencies using the canDelete() method. The canDelete() method has
one parameter, a two dimensional array.


Pages:
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89