diff options
author | Oleg Pudeyev <oleg@bsdpower.com> | 2012-03-08 08:44:32 -0500 |
---|---|---|
committer | Oleg Pudeyev <oleg@bsdpower.com> | 2012-03-08 08:44:32 -0500 |
commit | 35309de0b77e8af18a03a2da5b8196668164c040 (patch) | |
tree | a30aec0883d2377fe19e4874b8a3938d7b4c0b92 /phpBB/includes/db/dbal.php | |
parent | 65e711cbb0314dea5895308d1558453d222240e2 (diff) | |
parent | d380a1a36ffd5b2de6e403eb63f8754d8a277386 (diff) | |
download | forums-35309de0b77e8af18a03a2da5b8196668164c040.tar forums-35309de0b77e8af18a03a2da5b8196668164c040.tar.gz forums-35309de0b77e8af18a03a2da5b8196668164c040.tar.bz2 forums-35309de0b77e8af18a03a2da5b8196668164c040.tar.xz forums-35309de0b77e8af18a03a2da5b8196668164c040.zip |
Merge branch 'develop-olympus' into develop
* develop-olympus:
[ticket/10653] Call get_row_count of base class in mysql get_estimated_row_count
[ticket/9813] Only get posts table row count if we detected a fulltext index.
[ticket/9813] Also use estimated row count of posts table for fulltext mysql.
[ticket/10653] Fix parameter to substr() in unit tests. Should be 1, not -1.
[ticket/10653] Unit tests for get_row_count() and get_estimated_row_count().
[ticket/10653] Add ability to count table rows to database abstraction layer.
[ticket/9813] Use table status row count only if greater than 100000 or exact.
[ticket/9813] Use SHOW TABLE STATUS to get search stats for native on MySQL.
Diffstat (limited to 'phpBB/includes/db/dbal.php')
-rw-r--r-- | phpBB/includes/db/dbal.php | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php index 8564cb8426..6da854b6e2 100644 --- a/phpBB/includes/db/dbal.php +++ b/phpBB/includes/db/dbal.php @@ -920,6 +920,41 @@ class dbal return true; } + + /** + * Gets the estimated number of rows in a specified table. + * + * @param string $table_name Table name + * + * @return string Number of rows in $table_name. + * Prefixed with ~ if estimated (otherwise exact). + * + * @access public + */ + function get_estimated_row_count($table_name) + { + return $this->get_row_count($table_name); + } + + /** + * Gets the exact number of rows in a specified table. + * + * @param string $table_name Table name + * + * @return string Exact number of rows in $table_name. + * + * @access public + */ + function get_row_count($table_name) + { + $sql = 'SELECT COUNT(*) AS rows_total + FROM ' . $this->sql_escape($table_name); + $result = $this->sql_query($sql); + $rows_total = $this->sql_fetchfield('rows_total'); + $this->sql_freeresult($result); + + return $rows_total; + } } /** |