An alternative to affected_rows() for insert_batch() and update_batch() (ref #126)
diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php
index 5fc3d18..5ea9643 100644
--- a/system/database/DB_query_builder.php
+++ b/system/database/DB_query_builder.php
@@ -1216,9 +1216,9 @@
 	 *
 	 * Compiles batch insert strings and runs the queries
 	 *
-	 * @param	string	the table to retrieve the results from
-	 * @param	array	an associative array of insert values
-	 * @return	object
+	 * @param	string	$table = ''	table to insert into
+	 * @param	array	$set 		an associative array of insert values
+	 * @return	int	number of rows inserted or FALSE on failure
 	 */
 	public function insert_batch($table = '', $set = NULL)
 	{
@@ -1229,12 +1229,8 @@
 
 		if (count($this->qb_set) === 0)
 		{
-			if ($this->db_debug)
-			{
-				// No valid data array. Folds in cases where keys and values did not match up
-				return $this->display_error('db_must_use_set');
-			}
-			return FALSE;
+			// No valid data array. Folds in cases where keys and values did not match up
+			return ($this->db_debug) ? $this->display_error('db_must_use_set') : FALSE;
 		}
 
 		if ($table === '')
@@ -1248,13 +1244,15 @@
 		}
 
 		// Batch this baby
+		$affected_rows = 0;
 		for ($i = 0, $total = count($this->qb_set); $i < $total; $i += 100)
 		{
 			$this->query($this->_insert_batch($this->protect_identifiers($table, TRUE, NULL, FALSE), $this->qb_keys, array_slice($this->qb_set, $i, 100)));
+			$affected_rows += $this->affected_rows();
 		}
 
 		$this->_reset_write();
-		return TRUE;
+		return $affected_rows;
 	}
 
 	// --------------------------------------------------------------------
@@ -1621,7 +1619,7 @@
 	 * @param	string	the table to retrieve the results from
 	 * @param	array	an associative array of update values
 	 * @param	string	the where key
-	 * @return	bool
+	 * @return	int	number of rows affected or FALSE on failure
 	 */
 	public function update_batch($table = '', $set = NULL, $index = NULL)
 	{
@@ -1654,13 +1652,15 @@
 		}
 
 		// Batch this baby
+		$affected_rows = 0;
 		for ($i = 0, $total = count($this->qb_set); $i < $total; $i += 100)
 		{
 			$this->query($this->_update_batch($this->protect_identifiers($table, TRUE, NULL, FALSE), array_slice($this->qb_set, $i, 100), $this->protect_identifiers($index)));
+			$affected_rows += $this->affected_rows();
 		}
 
 		$this->_reset_write();
-		return TRUE;
+		return $affected_rows;
 	}
 
 	// --------------------------------------------------------------------
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 9aa4f5f..de5ec47 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -95,6 +95,7 @@
 	 - Added support for *USING* in ``join()``.
 	 - Changed ``limit()`` to ignore NULL values instead of always casting to integer.
 	 - Changed ``offset()`` to ignore empty values instead of always casting to integer.
+	 - Methods ``insert_batch()`` and ``update_batch()`` now return an integer representing the number of rows affected by them.
    -  Improved support for the MySQLi driver, including:
 	 - OOP style of the PHP extension is now used, instead of the procedural aliases.
 	 - Server version checking is now done via ``mysqli::$server_info`` instead of running an SQL query.
diff --git a/user_guide_src/source/database/query_builder.rst b/user_guide_src/source/database/query_builder.rst
index b86a0c8..6ca7291 100644
--- a/user_guide_src/source/database/query_builder.rst
+++ b/user_guide_src/source/database/query_builder.rst
@@ -830,6 +830,10 @@
 
 .. note:: All values are escaped automatically producing safer queries.
 
+.. note:: ``affected_rows()`` won't give you proper results with this method,
+	due to the very nature of how it works. Instead, ``update_batch()``
+	returns the number of rows affected.
+
 $this->db->get_compiled_update()
 ================================