summaryrefslogtreecommitdiffstats
path: root/system/database/DB_driver.php
diff options
context:
space:
mode:
Diffstat (limited to 'system/database/DB_driver.php')
-rw-r--r--system/database/DB_driver.php32
1 files changed, 30 insertions, 2 deletions
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index d8a1c13f0..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
*/