Book Image

Learning Joomla! 1.5 Extension Development

Book Image

Learning Joomla! 1.5 Extension Development

Overview of this book

Table of Contents (17 chapters)
Learning Joomla! 1.5 Extension Development
Credits
About the Author
About the Reviewer
Preface

Recording traffic


As we display records on the publicly-accessible Internet, it is often desirable to keep track of how many times a specific record has been accessed. The hit() member function of JTable can do this, assuming that your table has a column named hits. To demonstrate this, add a function named showCritic() with the following code to the controller in the /components/com_critic/critic.php file:

function showCritic()
{
$id = JRequest::getInt('id', 0);
$row =& JTable::getInstance('critic', 'Table');
$row->load($id);
$row->hit($id);
?>
<p><strong><?php echo $row->name; ?></strong></p>
<p>Favorite food: <?php echo $row->favorite_food; ?></p>
<p><?php echo $row->bio; ?></p>
<?php
}

The function first extracts id from the request and makes sure that it is an integer. After this, a reference to a TableCritic object is assigned to $row. The load() member function of $row is called to pull...