diff options
-rw-r--r-- | system/drivers/DB_driver.php | 20 | ||||
-rw-r--r-- | system/drivers/DB_mssql.php | 7 | ||||
-rw-r--r-- | system/drivers/DB_mysql.php | 7 | ||||
-rw-r--r-- | system/drivers/DB_mysqli.php | 7 | ||||
-rw-r--r-- | system/drivers/DB_oci8.php | 7 | ||||
-rw-r--r-- | system/drivers/DB_odbc.php | 7 | ||||
-rw-r--r-- | system/drivers/DB_postgre.php | 7 | ||||
-rw-r--r-- | system/drivers/DB_sqlite.php | 7 | ||||
-rw-r--r-- | user_guide/libraries/database/index.html | 1 |
9 files changed, 59 insertions, 11 deletions
diff --git a/system/drivers/DB_driver.php b/system/drivers/DB_driver.php index b05cd7c5b..a1ec14b06 100644 --- a/system/drivers/DB_driver.php +++ b/system/drivers/DB_driver.php @@ -316,7 +316,7 @@ class CI_DB_driver { * @access public * @return void */ - function trans_start() + function trans_start($test_mode = FALSE) { if ( ! $this->trans_enabled) { @@ -330,9 +330,7 @@ class CI_DB_driver { return; } - // Reset the transaction failure flag - $this->_trans_failure = FALSE; - $this->trans_begin(); + $this->trans_begin($test_mode); } // -------------------------------------------------------------------- @@ -376,6 +374,20 @@ class CI_DB_driver { // -------------------------------------------------------------------- /** + * Lets you retrieve the transaction flag to determine if it has failed + * + * @access public + * @return bool + */ + function trans_status() + { + return $this->_trans_failure; + } + + + // -------------------------------------------------------------------- + + /** * Enables a native PHP function to be run, using a platform agnostic wrapper. * * @access public diff --git a/system/drivers/DB_mssql.php b/system/drivers/DB_mssql.php index 3fbfa6a3f..32c0537c3 100644 --- a/system/drivers/DB_mssql.php +++ b/system/drivers/DB_mssql.php @@ -106,7 +106,7 @@ class CI_DB_mssql extends CI_DB { * @access public * @return bool */ - function trans_begin() + function trans_begin($test_mode = FALSE) { if ( ! $this->trans_enabled) { @@ -119,6 +119,11 @@ class CI_DB_mssql extends CI_DB { return TRUE; } + // Reset the transaction failure flag. + // If the $test_mode flag is set to TRUE transactions will be rolled back + // even if the queries produce a successful result. + $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE; + $this->simple_query('BEGIN TRAN'); return TRUE; } diff --git a/system/drivers/DB_mysql.php b/system/drivers/DB_mysql.php index 69a6db0eb..208f09c25 100644 --- a/system/drivers/DB_mysql.php +++ b/system/drivers/DB_mysql.php @@ -123,7 +123,7 @@ class CI_DB_mysql extends CI_DB { * @access public * @return bool */ - function trans_begin() + function trans_begin($test_mode = FALSE) { if ( ! $this->trans_enabled) { @@ -136,6 +136,11 @@ class CI_DB_mysql extends CI_DB { return TRUE; } + // Reset the transaction failure flag. + // If the $test_mode flag is set to TRUE transactions will be rolled back + // even if the queries produce a successful result. + $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE; + $this->simple_query('SET AUTOCOMMIT=0'); $this->simple_query('START TRANSACTION'); // can also be BEGIN or BEGIN WORK return TRUE; diff --git a/system/drivers/DB_mysqli.php b/system/drivers/DB_mysqli.php index a5237c832..288f552dd 100644 --- a/system/drivers/DB_mysqli.php +++ b/system/drivers/DB_mysqli.php @@ -127,7 +127,7 @@ class CI_DB_mysqli extends CI_DB { * @access public * @return bool */ - function trans_begin() + function trans_begin($test_mode = FALSE) { if ( ! $this->trans_enabled) { @@ -140,6 +140,11 @@ class CI_DB_mysqli extends CI_DB { return TRUE; } + // Reset the transaction failure flag. + // If the $test_mode flag is set to TRUE transactions will be rolled back + // even if the queries produce a successful result. + $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE; + $this->simple_query('SET AUTOCOMMIT=0'); $this->simple_query('START TRANSACTION'); // can also be BEGIN or BEGIN WORK return TRUE; diff --git a/system/drivers/DB_oci8.php b/system/drivers/DB_oci8.php index 2f936da12..a88b474bd 100644 --- a/system/drivers/DB_oci8.php +++ b/system/drivers/DB_oci8.php @@ -245,7 +245,7 @@ class CI_DB_oci8 extends CI_DB { * @access public * @return bool */ - function trans_begin() + function trans_begin($test_mode = FALSE) { if ( ! $this->trans_enabled) { @@ -258,6 +258,11 @@ class CI_DB_oci8 extends CI_DB { return TRUE; } + // Reset the transaction failure flag. + // If the $test_mode flag is set to TRUE transactions will be rolled back + // even if the queries produce a successful result. + $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE; + $this->_commit = OCI_DEFAULT; return TRUE; } diff --git a/system/drivers/DB_odbc.php b/system/drivers/DB_odbc.php index a32e9e072..cdd2f4513 100644 --- a/system/drivers/DB_odbc.php +++ b/system/drivers/DB_odbc.php @@ -107,7 +107,7 @@ class CI_DB_odbc extends CI_DB { * @access public * @return bool */ - function trans_begin() + function trans_begin($test_mode = FALSE) { if ( ! $this->trans_enabled) { @@ -120,6 +120,11 @@ class CI_DB_odbc extends CI_DB { return TRUE; } + // Reset the transaction failure flag. + // If the $test_mode flag is set to TRUE transactions will be rolled back + // even if the queries produce a successful result. + $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE; + return odbc_autocommit($this->conn_id, FALSE); } diff --git a/system/drivers/DB_postgre.php b/system/drivers/DB_postgre.php index fe7c704f9..bd5fbac24 100644 --- a/system/drivers/DB_postgre.php +++ b/system/drivers/DB_postgre.php @@ -111,7 +111,7 @@ class CI_DB_postgre extends CI_DB { * @access public * @return bool */ - function trans_begin() + function trans_begin($test_mode = FALSE) { if ( ! $this->trans_enabled) { @@ -124,6 +124,11 @@ class CI_DB_postgre extends CI_DB { return TRUE; } + // Reset the transaction failure flag. + // If the $test_mode flag is set to TRUE transactions will be rolled back + // even if the queries produce a successful result. + $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE; + return @pg_exec($this->conn_id, "begin"); } diff --git a/system/drivers/DB_sqlite.php b/system/drivers/DB_sqlite.php index 6d7b4294a..b21241a1f 100644 --- a/system/drivers/DB_sqlite.php +++ b/system/drivers/DB_sqlite.php @@ -128,7 +128,7 @@ class CI_DB_sqlite extends CI_DB { * @access public * @return bool */ - function trans_begin() + function trans_begin($test_mode = FALSE) { if ( ! $this->trans_enabled) { @@ -141,6 +141,11 @@ class CI_DB_sqlite extends CI_DB { return TRUE; } + // Reset the transaction failure flag. + // If the $test_mode flag is set to TRUE transactions will be rolled back + // even if the queries produce a successful result. + $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE; + $this->simple_query('BEGIN TRANSACTION'); return TRUE; } diff --git a/user_guide/libraries/database/index.html b/user_guide/libraries/database/index.html index ed118ad60..d50ff9292 100644 --- a/user_guide/libraries/database/index.html +++ b/user_guide/libraries/database/index.html @@ -74,6 +74,7 @@ structures and Active Record patterns. The database functions offer clear, simpl <li><a href="queries.html">Queries</a></li>
<li><a href="results.html">Query Results</a></li>
<li><a href="active_record.html">Active Record Class</a></li>
+ <li><a href="transactions.html">Transactions</a></li>
<li><a href="fields.html">Field MetaData</a></li>
<li><a href="table_data.html">Table MetaData</a></li>
<li><a href="call_function.html">Custom Function Calls</a></li>
|