我使用查询forsearch函数。当我搜索db中很少的关键字时一切顺利。但是,当关键字在数据库中“流行”时,屏幕会变为空白页。
function dbSearch($q) //$q is array of keywords
{
global $mainframe, $option;
$db =& JFactory::getDBO();
$str = implode("%' AND text LIKE '%", $q);
$str = str_replace("AND text LIKE '%-", "AND text NOT LIKE '%", $str);
$lim = $mainframe->getUserStateFromRequest("$option.limit", 'limit', 100, 'int');
$lim0 = JRequest::getVar('limitstart', 0, '', 'int');
$query = "SELECT SQL_CALC_FOUND_ROWS * FROM `table` WHERE type=4 AND text LIKE '%".$str."%' ORDER BY ref ASC";
$db->setQuery( $query );
$rows = $db->loadObjectList();
$count = count($rows);
if ($db->getErrorNum())
{
echo $db->stderr();
return false;
}
$db->setQuery('SELECT FOUND_ROWS();');
jimport('joomla.html.pagination');
$pageNav = new JPagination( $db->loadResult(), $lim0, $lim );
HTML_output::showFoundResults($rows, $pageNav, $count);
}上面的查询有问题吗?为什么它在众多结果上失败?