mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
[ticket/11179] add search query in case initial one fails
changes the start parameter according to the total search results and executes the search query again to get the results. PHPBB3-11179
This commit is contained in:
parent
0f89b48820
commit
737b99966d
1 changed files with 32 additions and 2 deletions
|
@ -381,7 +381,6 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
|
|||
{
|
||||
return $result_count;
|
||||
}
|
||||
|
||||
$id_ary = array();
|
||||
|
||||
$join_topic = ($type == 'posts') ? false : true;
|
||||
|
@ -490,7 +489,38 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
|
|||
|
||||
if (!sizeof($id_ary))
|
||||
{
|
||||
return false;
|
||||
$sql_count = "SELECT COUNT(*) as result_count
|
||||
FROM $sql_from$sql_sort_table" . POSTS_TABLE . " p
|
||||
WHERE MATCH ($sql_match) AGAINST ('" . $this->db->sql_escape(htmlspecialchars_decode($this->search_query)) . "' IN BOOLEAN MODE)
|
||||
$sql_where_options
|
||||
ORDER BY $sql_sort";
|
||||
$result = $this->db->sql_query($sql_count);
|
||||
$total_match_count = (int) $this->db->sql_fetchfield('result_count');
|
||||
|
||||
if ($total_match_count)
|
||||
{
|
||||
if ($start < 0)
|
||||
{
|
||||
$start = 0;
|
||||
}
|
||||
else if ($start >= $total_match_count)
|
||||
{
|
||||
$start = floor(($total_match_count - 1) / $per_page) * $per_page;
|
||||
}
|
||||
$result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start);
|
||||
while ($row = $this->db->sql_fetchrow($result))
|
||||
{
|
||||
$id_ary[] = (int) $row[$field];
|
||||
}
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
$id_ary = array_unique($id_ary);
|
||||
}
|
||||
|
||||
if (!sizeof($id_ary))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// if the total result count is not cached yet, retrieve it from the db
|
||||
|
|
Loading…
Add table
Reference in a new issue