Added support for limit() into update() and delete() statements in Active Record.
diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php
index 4a88bd8..cea9bdd 100644
--- a/system/database/DB_active_rec.php
+++ b/system/database/DB_active_rec.php
@@ -856,12 +856,12 @@
 			$table = $this->ar_from[0];

 		}

 		

-		if ($where != null)

+		if ($where != NULL)

 		{

 			$this->where($where);

 		}

 

-		if ($limit != null)

+		if ($limit != NULL)

 		{

 			$this->limit($limit);

 		}

@@ -884,7 +884,7 @@
 	 * @param	mixed	the where clause

 	 * @return	object

 	 */

-	function delete($table = '', $where = '')

+	function delete($table = '', $where = '', $limit = NULL)

 	{

 		if ($table == '')

 		{

@@ -905,6 +905,11 @@
 			$this->where($where);

 		}

 

+		if ($limit != NULL)

+		{

+			$this->limit($limit);

+		}

+

 		if (count($this->ar_where) == 0)

 		{

 			if ($this->db_debug)

@@ -914,7 +919,7 @@
 			return FALSE;

 		}		

 		

-		$sql = $this->_delete($this->dbprefix.$table, $this->ar_where);

+		$sql = $this->_delete($this->dbprefix.$table, $this->ar_where, $this->ar_limit);

 

 		$this->_reset_write();

 		return $this->query($sql);

@@ -1096,7 +1101,7 @@
 	/**

 	 * Resets the active record "write" values.

 	 *

-	 * Called by the insert() or update() functions

+	 * Called by the insert() update() and delete() functions

 	 *

 	 * @access	private

 	 * @return	void

diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php
index 613be69..044fb3c 100644
--- a/system/database/drivers/mssql/mssql_driver.php
+++ b/system/database/drivers/mssql/mssql_driver.php
@@ -445,9 +445,11 @@
 	 * @param	array	the where clause

 	 * @return	string

 	 */	

-	function _delete($table, $where)

+	function _delete($table, $where, $limit = FALSE)

 	{

-		return "DELETE FROM ".$this->_escape_table($table)." WHERE ".implode(" ", $where);

+		$limit = (!$limit) ? '' : ' LIMIT '.$limit;

+	

+		return "DELETE FROM ".$this->_escape_table($table)." WHERE ".implode(" ", $where).$limit;

 	}

 

 	// --------------------------------------------------------------------

diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php
index aaa9cc6..cd86ebf 100644
--- a/system/database/drivers/mysql/mysql_driver.php
+++ b/system/database/drivers/mysql/mysql_driver.php
@@ -463,9 +463,11 @@
 	 * @param	array	the where clause

 	 * @return	string

 	 */	

-	function _delete($table, $where)

+	function _delete($table, $where, $limit = FALSE)

 	{

-		return "DELETE FROM ".$this->_escape_table($table)." WHERE ".implode(" ", $where);

+		$limit = (!$limit) ? '' : ' LIMIT '.$limit;

+	

+		return "DELETE FROM ".$this->_escape_table($table)." WHERE ".implode(" ", $where).$limit;

 	}

 

 	// --------------------------------------------------------------------

diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php
index f6f106e..ebed813 100644
--- a/system/database/drivers/mysqli/mysqli_driver.php
+++ b/system/database/drivers/mysqli/mysqli_driver.php
@@ -456,9 +456,11 @@
 	 * @param	array	the where clause

 	 * @return	string

 	 */	

-	function _delete($table, $where)

+	function _delete($table, $where, $limit = FALSE)

 	{

-		return "DELETE FROM ".$this->_escape_table($table)." WHERE ".implode(" ", $where);

+		$limit = (!$limit) ? '' : ' LIMIT '.$limit;

+	

+		return "DELETE FROM ".$this->_escape_table($table)." WHERE ".implode(" ", $where).$limit;

 	}

 

 	// --------------------------------------------------------------------

diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php
index 1dd157c..c4ab700 100644
--- a/system/database/drivers/oci8/oci8_driver.php
+++ b/system/database/drivers/oci8/oci8_driver.php
@@ -559,9 +559,11 @@
 	 * @param   array   the where clause

 	 * @return  string

 	 */

-	function _delete($table, $where)

+	function _delete($table, $where, $limit = FALSE)

 	{

-		return "DELETE FROM ".$this->_escape_table($table)." WHERE ".implode(" ", $where);

+		$limit = (!$limit) ? '' : ' LIMIT '.$limit;

+	

+		return "DELETE FROM ".$this->_escape_table($table)." WHERE ".implode(" ", $where).$limit;

 	}

 

 	// --------------------------------------------------------------------

diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php
index 66d5f89..040ffed 100644
--- a/system/database/drivers/odbc/odbc_driver.php
+++ b/system/database/drivers/odbc/odbc_driver.php
@@ -418,9 +418,11 @@
 	 * @param	array	the where clause

 	 * @return	string

 	 */	

-	function _delete($table, $where)

+	function _delete($table, $where, $limit = FALSE)

 	{

-		return "DELETE FROM ".$this->_escape_table($table)." WHERE ".implode(" ", $where);

+		$limit = (!$limit) ? '' : ' LIMIT '.$limit;

+	

+		return "DELETE FROM ".$this->_escape_table($table)." WHERE ".implode(" ", $where).$limit;

 	}

 

 	// --------------------------------------------------------------------

diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
index 076d87a..88f08b2 100644
--- a/system/database/drivers/postgre/postgre_driver.php
+++ b/system/database/drivers/postgre/postgre_driver.php
@@ -447,9 +447,11 @@
 	 * @param	array	the where clause

 	 * @return	string

 	 */	

-	function _delete($table, $where)

+	function _delete($table, $where, $limit = FALSE)

 	{

-		return "DELETE FROM ".$this->_escape_table($table)." WHERE ".implode(" ", $where);

+		$limit = (!$limit) ? '' : ' LIMIT '.$limit;

+	

+		return "DELETE FROM ".$this->_escape_table($table)." WHERE ".implode(" ", $where).$limit;

 	}

 

 	// --------------------------------------------------------------------

diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php
index b701d6b..6189b1f 100644
--- a/system/database/drivers/sqlite/sqlite_driver.php
+++ b/system/database/drivers/sqlite/sqlite_driver.php
@@ -442,9 +442,11 @@
 	 * @param	array	the where clause

 	 * @return	string

 	 */	

-	function _delete($table, $where)

+	function _delete($table, $where, $limit = FALSE)

 	{

-		return "DELETE FROM ".$this->_escape_table($table)." WHERE ".implode(" ", $where);

+		$limit = (!$limit) ? '' : ' LIMIT '.$limit;

+	

+		return "DELETE FROM ".$this->_escape_table($table)." WHERE ".implode(" ", $where).$limit;

 	}

 

 	// --------------------------------------------------------------------