diff options
author | Phil Sturgeon <email@philsturgeon.co.uk> | 2012-05-27 22:53:25 +0200 |
---|---|---|
committer | Phil Sturgeon <email@philsturgeon.co.uk> | 2012-05-27 22:53:25 +0200 |
commit | 2d8707f8ba27f16a226d85a011aeab5325b27100 (patch) | |
tree | f94af6e8b63a8632c45965c2f907a1abd76c6436 /system/database/DB_driver.php | |
parent | f777d3ddafcd2a79bbc65d329e1f9586c3a449fb (diff) | |
parent | 11fd4b8759438f216318e3e1e004f918b88a56ad (diff) |
Merge branch 'develop' of github.com:EllisLab/CodeIgniter into develop
Diffstat (limited to 'system/database/DB_driver.php')
-rw-r--r-- | system/database/DB_driver.php | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index a0812d4c7..bbb7b7a80 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -742,6 +742,35 @@ abstract class CI_DB_driver { // -------------------------------------------------------------------- /** + * "Count All" query + * + * Generates a platform-specific query string that counts all records in + * the specified database + * + * @param string + * @return int + */ + public function count_all($table = '') + { + if ($table == '') + { + return 0; + } + + $query = $this->query($this->_count_string.$this->escape_identifiers('numrows').' FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE)); + if ($query->num_rows() == 0) + { + return 0; + } + + $query = $query->row(); + $this->_reset_select(); + return (int) $query->numrows; + } + + // -------------------------------------------------------------------- + + /** * Returns an array of table names * * @return array @@ -1395,8 +1424,7 @@ abstract class CI_DB_driver { /** * Dummy method that allows Query Builder class to be disabled - * - * This function is used extensively by every db driver. + * and keep count_all() working. * * @return void */ @@ -1404,23 +1432,6 @@ abstract class CI_DB_driver { { } - // -------------------------------------------------------------------- - - /** - * Destructor - * - * Closes the database connection, if needed. - * - * @return void - */ - public function __destruct() - { - if ( ! $this->pconnect) - { - $this->close(); - } - } - } /* End of file DB_driver.php */ |