aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/search
diff options
context:
space:
mode:
authorDhruv <dhruv.goel92@gmail.com>2012-12-03 01:07:47 +0530
committerOleg Pudeyev <oleg@bsdpower.com>2012-12-30 18:50:09 -0500
commit763f2929babcb65b503a60f712bfc552f1e296f9 (patch)
treeb7c66d69b97db0d785331230d9eb5f0642458ffd /phpBB/includes/search
parent979edc4113f8b9ecb3aa4e7d445a5b59eefd78ff (diff)
downloadforums-763f2929babcb65b503a60f712bfc552f1e296f9.tar
forums-763f2929babcb65b503a60f712bfc552f1e296f9.tar.gz
forums-763f2929babcb65b503a60f712bfc552f1e296f9.tar.bz2
forums-763f2929babcb65b503a60f712bfc552f1e296f9.tar.xz
forums-763f2929babcb65b503a60f712bfc552f1e296f9.zip
[ticket/11188] add result count query for author search
PHPBB3-11188
Diffstat (limited to 'phpBB/includes/search')
-rw-r--r--phpBB/includes/search/fulltext_postgres.php34
1 files changed, 33 insertions, 1 deletions
diff --git a/phpBB/includes/search/fulltext_postgres.php b/phpBB/includes/search/fulltext_postgres.php
index a9b122931b..7d7b3f6fa8 100644
--- a/phpBB/includes/search/fulltext_postgres.php
+++ b/phpBB/includes/search/fulltext_postgres.php
@@ -656,6 +656,8 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
$field = 'topic_id';
}
+ $this->db->sql_transaction('begin');
+
// 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);
@@ -668,7 +670,35 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
// retrieve the total result count if needed
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)
{
@@ -676,6 +706,8 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
}
}
+ $this->db->sql_transaction('commit');
+
if (sizeof($id_ary))
{
$this->save_ids($search_key, '', $author_ary, $result_count, $id_ary, $start, $sort_dir);