diff options
author | Dhruv <dhruv.goel92@gmail.com> | 2015-03-14 23:44:58 +0800 |
---|---|---|
committer | Dhruv <dhruv.goel92@gmail.com> | 2015-03-14 23:44:58 +0800 |
commit | 24f26478c4bf20799ea610cd672a96af818a1be6 (patch) | |
tree | 550098c26b9add16b9b0a99b032de91c40d10a5b /phpBB/phpbb/search/fulltext_native.php | |
parent | a2454285bd32ae8df24b62dea648de3b293a5f41 (diff) | |
parent | f0619b481f200dd225f98709fad2d1662ec3cdff (diff) | |
download | forums-24f26478c4bf20799ea610cd672a96af818a1be6.tar forums-24f26478c4bf20799ea610cd672a96af818a1be6.tar.gz forums-24f26478c4bf20799ea610cd672a96af818a1be6.tar.bz2 forums-24f26478c4bf20799ea610cd672a96af818a1be6.tar.xz forums-24f26478c4bf20799ea610cd672a96af818a1be6.zip |
Merge branch '3.1.x'
Conflicts:
phpBB/phpbb/search/fulltext_native.php
Diffstat (limited to 'phpBB/phpbb/search/fulltext_native.php')
-rw-r--r-- | phpBB/phpbb/search/fulltext_native.php | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/phpBB/phpbb/search/fulltext_native.php b/phpBB/phpbb/search/fulltext_native.php index b18015ba1a..42ad97da30 100644 --- a/phpBB/phpbb/search/fulltext_native.php +++ b/phpBB/phpbb/search/fulltext_native.php @@ -826,6 +826,13 @@ class fulltext_native extends \phpbb\search\base ); } + // if using mysql and the total result count is not calculated yet, get it from the db + if (!$total_results && $is_mysql) + { + // Also count rows for the query as if there was not LIMIT. Add SQL_CALC_FOUND_ROWS to SQL + $sql_array['SELECT'] = 'SQL_CALC_FOUND_ROWS ' . $sql_array['SELECT']; + } + $sql_array['WHERE'] = implode(' AND ', $sql_where); $sql_array['GROUP_BY'] = ($group_by) ? (($type == 'posts') ? 'p.post_id' : 'p.topic_id') . ', ' . $sort_by_sql[$sort_key] : ''; $sql_array['ORDER_BY'] = $sql_sort; @@ -841,19 +848,9 @@ class fulltext_native extends \phpbb\search\base } $this->db->sql_freeresult($result); - // if we use mysql and the total result count is not cached yet, retrieve it from the db if (!$total_results && $is_mysql) { - // Count rows for the executed queries. Replace $select within $sql with SQL_CALC_FOUND_ROWS, and run it - $sql_array_copy = $sql_array; - $sql_array_copy['SELECT'] = 'SQL_CALC_FOUND_ROWS p.post_id '; - - $sql_calc = $this->db->sql_build_query('SELECT', $sql_array_copy); - unset($sql_array_copy); - - $result = $this->db->sql_query($sql_calc); - $this->db->sql_freeresult($result); - + // Get the number of results as calculated by MySQL $sql_count = 'SELECT FOUND_ROWS() as total_results'; $result = $this->db->sql_query($sql_count); $total_results = (int) $this->db->sql_fetchfield('total_results'); |