1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-09 02:06:32 +02:00

[ticket/10653] Add ability to count table rows to database abstraction layer.

PHPBB3-10653
This commit is contained in:
Andreas Fischer
2012-02-18 19:29:32 +01:00
parent 97cf433dea
commit f9953fc339
4 changed files with 177 additions and 44 deletions

View File

@@ -900,6 +900,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;
}
}
/**