Merge branch 'develop' of git://github.com/EllisLab/CodeIgniter into develop
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index dd1b567..cc40ba4 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -522,6 +522,7 @@
 		}
 
 		$this->trans_begin($test_mode);
+		$this->_trans_depth += 1;
 	}
 
 	// --------------------------------------------------------------------
@@ -545,6 +546,10 @@
 			$this->_trans_depth -= 1;
 			return TRUE;
 		}
+		else
+		{
+			$this->_trans_depth = 0;
+		}
 
 		// The query() function will set this flag to FALSE in the event that a query failed
 		if ($this->_trans_status === FALSE)
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index de2b366..b9ca39c 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -57,6 +57,7 @@
 -  Unlink raised an error if cache file did not exist when you try to delete it.
 -  Fixed a bug (#181) where a mis-spelling was in the form validation
    language file.
+-  Fixed a bug (#159, #163) that mishandled Active Record nested transactions because _trans_depth was not getting incremented.
 
 
 Version 2.1.0