[ticket/11188] add result count query for author search

PHPBB3-11188
This commit is contained in:
Dhruv 2012-12-03 01:07:47 +05:30 committed by Oleg Pudeyev
parent 979edc4113
commit 763f2929ba

View file

@ -656,6 +656,8 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
$field = 'topic_id'; $field = 'topic_id';
} }
$this->db->sql_transaction('begin');
// Only read one block of posts from the db and then cache it // Only read one block of posts from the db and then cache it
$result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start); $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start);
@ -668,7 +670,35 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
// retrieve the total result count if needed // retrieve the total result count if needed
if (!$result_count) if (!$result_count)
{ {
$result_count = sizeof ($id_ary); if ($type == 'posts')
{
$sql_count = "SELECT COUNT(*) as result_count
FROM " . $sql_sort_table . POSTS_TABLE . ' p' . (($firstpost_only) ? ', ' . TOPICS_TABLE . ' t ' : ' ') . "
WHERE $sql_author
$sql_topic_id
$sql_firstpost
$m_approve_fid_sql
$sql_fora
$sql_sort_join
$sql_time";
}
else
{
$sql_count = "SELECT COUNT(*) as result_count
FROM " . $sql_sort_table . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p
WHERE $sql_author
$sql_topic_id
$sql_firstpost
$m_approve_fid_sql
$sql_fora
AND t.topic_id = p.topic_id
$sql_sort_join
$sql_time
GROUP BY t.topic_id, $sort_by_sql[$sort_key]";
}
$result = $this->db->sql_query($sql_count);
$result_count = (int) $this->db->sql_fetchfield('result_count');
if (!$result_count) if (!$result_count)
{ {
@ -676,6 +706,8 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
} }
} }
$this->db->sql_transaction('commit');
if (sizeof($id_ary)) if (sizeof($id_ary))
{ {
$this->save_ids($search_key, '', $author_ary, $result_count, $id_ary, $start, $sort_dir); $this->save_ids($search_key, '', $author_ary, $result_count, $id_ary, $start, $sort_dir);