Source for file helper.php
Documentation is available at helper.php
* @package Joomla.Libraries
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* Helper class for Joomla! Search components
* @package Joomla.Libraries
* Method to log search terms to the database
* @param string $term The term being searched
* @param string $component The component being used for the search
public static function logSearch($term, $component)
// Initialise our variables
$query =
$db->getQuery(true);
// Sanitise the term for the database
if ($enable_log_searches)
// Query the table to determine if the term has been searched previously
$query->select($db->quoteName('hits'))
->from($db->quoteName('#__core_log_searches'))
->where($db->quoteName('search_term') .
' = ' .
$db->quote($search_term));
$hits =
intval($db->loadResult());
// Reset the $query object
// Update the table based on the results
$query->update($db->quoteName('#__core_log_searches'))
->set('hits = (hits + 1)')
->where($db->quoteName('search_term') .
' = ' .
$db->quote($search_term));
$query->insert($db->quoteName('#__core_log_searches'))
->columns(array($db->quoteName('search_term'), $db->quoteName('hits')))
->values($db->quote($search_term) .
', 1');
// Execute the update query
Documentation generated on Tue, 19 Nov 2013 15:04:31 +0100 by phpDocumentor 1.4.3