diff options
author | Andreas Fischer <bantu@phpbb.com> | 2012-02-18 19:29:32 +0100 |
---|---|---|
committer | Andreas Fischer <bantu@phpbb.com> | 2012-03-03 21:04:01 +0100 |
commit | f9953fc3395e6b206c0789d40f89f9d2463348e7 (patch) | |
tree | ab9160650d7178ce814f67a3b2245e4c8f62a918 /phpBB/includes/search | |
parent | 97cf433dea658127ed60c70ea47d1c3830964f25 (diff) | |
download | forums-f9953fc3395e6b206c0789d40f89f9d2463348e7.tar forums-f9953fc3395e6b206c0789d40f89f9d2463348e7.tar.gz forums-f9953fc3395e6b206c0789d40f89f9d2463348e7.tar.bz2 forums-f9953fc3395e6b206c0789d40f89f9d2463348e7.tar.xz forums-f9953fc3395e6b206c0789d40f89f9d2463348e7.zip |
[ticket/10653] Add ability to count table rows to database abstraction layer.
PHPBB3-10653
Diffstat (limited to 'phpBB/includes/search')
-rw-r--r-- | phpBB/includes/search/fulltext_native.php | 46 |
1 files changed, 2 insertions, 44 deletions
diff --git a/phpBB/includes/search/fulltext_native.php b/phpBB/includes/search/fulltext_native.php index 69937ff9c9..dc961f3c8a 100644 --- a/phpBB/includes/search/fulltext_native.php +++ b/phpBB/includes/search/fulltext_native.php @@ -1459,52 +1459,10 @@ class fulltext_native extends search_backend function get_stats() { - $this->stats['total_words'] = $this->get_table_row_count(SEARCH_WORDLIST_TABLE); - $this->stats['total_matches'] = $this->get_table_row_count(SEARCH_WORDMATCH_TABLE); - } - - /** - * Gets statistics for a specific database table. - * - * @param string $table_name Table name - * - * @return string Row count. Prefixed with ~ if estimated. - * - * @access protected - */ - function get_table_row_count($table_name) - { global $db; - if (stripos($db->sql_layer, 'mysql') === 0) - { - $sql = "SHOW TABLE STATUS - LIKE '" . $table_name . "'"; - $result = $db->sql_query($sql); - $table_status = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (isset($table_status['Engine'])) - { - if ($table_status['Engine'] === 'MyISAM') - { - return $table_status['Rows']; - } - else if ($table_status['Engine'] === 'InnoDB' && $table_status['Rows'] > 100000) - { - return '~' . $table_status['Rows']; - } - } - } - - // Get exact row count by actually counting rows - $sql = 'SELECT COUNT(*) AS rows_total - FROM ' . $table_name; - $result = $db->sql_query($sql); - $rows_total = $db->sql_fetchfield('rows_total'); - $db->sql_freeresult($result); - - return $rows_total; + $this->stats['total_words'] = $db->get_estimated_row_count(SEARCH_WORDLIST_TABLE); + $this->stats['total_matches'] = $db->get_estimated_row_count(SEARCH_WORDMATCH_TABLE); } /** |