Added count_all_results() function to Active Record.
diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php
index 6a991a2..cb134ea 100644
--- a/system/database/DB_active_rec.php
+++ b/system/database/DB_active_rec.php
@@ -540,6 +540,7 @@
 	 * and runs the query

 	 *

 	 * @access	public

+	 * @param	string	the table

 	 * @param	string	the limit clause

 	 * @param	string	the offset clause

 	 * @return	object

@@ -566,6 +567,39 @@
 	// --------------------------------------------------------------------

 

 	/**

+	 * "Count All Results" query

+	 *

+	 * Generates a platform-specific query string that counts all records 

+	 * returned by an Active Record query.

+	 *

+	 * @access	public

+	 * @param	string

+	 * @return	string

+	 */

+	function count_all_results($table = '')

+	{

+		if ($table != '')

+		{

+			$this->from($table);

+		}

+		

+		$sql = $this->_compile_select($this->count_string);

+

+		$query = $this->query($sql);

+		$this->_reset_select();

+	

+		if ($query->num_rows() == 0)

+		{

+			return '0';

+		}

+

+		$row = $query->row();

+		return $row->numrows;

+	}

+

+	// --------------------------------------------------------------------

+

+	/**

 	 * Get_Where

 	 *

 	 * Allows the where clause, limit and offset to be added directly

@@ -806,12 +840,17 @@
 	 * @access	private

 	 * @return	string

 	 */

-	function _compile_select()

+	function _compile_select($select_override = FALSE)

 	{

 		$sql = ( ! $this->ar_distinct) ? 'SELECT ' : 'SELECT DISTINCT ';

 	

 		$sql .= (count($this->ar_select) == 0) ? '*' : implode(', ', $this->ar_select);

 

+		if ($select_override !== FALSE)

+		{

+			$sql = $select_override;

+		}

+

 		if (count($this->ar_from) > 0)

 		{

 			$sql .= "\nFROM ";