diff --git a/system/drivers/DB_mssql.php b/system/drivers/DB_mssql.php
index c842476..3fbfa6a 100644
--- a/system/drivers/DB_mssql.php
+++ b/system/drivers/DB_mssql.php
@@ -76,7 +76,7 @@
* @param string an SQL query
* @return resource
*/
- function execute($sql)
+ function _execute($sql)
{
$sql = $this->_prep_query($sql);
return @mssql_query($sql, $this->conn_id);
@@ -97,6 +97,81 @@
{
return $sql;
}
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Begin Transaction
+ *
+ * @access public
+ * @return bool
+ */
+ function trans_begin()
+ {
+ if ( ! $this->trans_enabled)
+ {
+ return TRUE;
+ }
+
+ // When transactions are nested we only begin/commit/rollback the outermost ones
+ if ($this->_trans_depth > 0)
+ {
+ return TRUE;
+ }
+
+ $this->simple_query('BEGIN TRAN');
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Commit Transaction
+ *
+ * @access public
+ * @return bool
+ */
+ function trans_commit()
+ {
+ if ( ! $this->trans_enabled)
+ {
+ return TRUE;
+ }
+
+ // When transactions are nested we only begin/commit/rollback the outermost ones
+ if ($this->_trans_depth > 0)
+ {
+ return TRUE;
+ }
+
+ $this->simple_query('COMMIT TRAN');
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Rollback Transaction
+ *
+ * @access public
+ * @return bool
+ */
+ function trans_rollback()
+ {
+ if ( ! $this->trans_enabled)
+ {
+ return TRUE;
+ }
+
+ // When transactions are nested we only begin/commit/rollback the outermost ones
+ if ($this->_trans_depth > 0)
+ {
+ return TRUE;
+ }
+
+ $this->simple_query('ROLLBACK TRAN');
+ return TRUE;
+ }
// --------------------------------------------------------------------
diff --git a/system/drivers/DB_mysqli.php b/system/drivers/DB_mysqli.php
index 4b96857..a5237c8 100644
--- a/system/drivers/DB_mysqli.php
+++ b/system/drivers/DB_mysqli.php
@@ -85,7 +85,7 @@
* @param string an SQL query
* @return resource
*/
- function execute($sql)
+ function _execute($sql)
{
$sql = $this->_prep_query($sql);
$result = @mysqli_query($this->conn_id, $sql);
@@ -117,7 +117,86 @@
return $sql;
}
-
+
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Begin Transaction
+ *
+ * @access public
+ * @return bool
+ */
+ function trans_begin()
+ {
+ if ( ! $this->trans_enabled)
+ {
+ return TRUE;
+ }
+
+ // When transactions are nested we only begin/commit/rollback the outermost ones
+ if ($this->_trans_depth > 0)
+ {
+ return TRUE;
+ }
+
+ $this->simple_query('SET AUTOCOMMIT=0');
+ $this->simple_query('START TRANSACTION'); // can also be BEGIN or BEGIN WORK
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Commit Transaction
+ *
+ * @access public
+ * @return bool
+ */
+ function trans_commit()
+ {
+ if ( ! $this->trans_enabled)
+ {
+ return TRUE;
+ }
+
+ // When transactions are nested we only begin/commit/rollback the outermost ones
+ if ($this->_trans_depth > 0)
+ {
+ return TRUE;
+ }
+
+ $this->simple_query('COMMIT');
+ $this->simple_query('SET AUTOCOMMIT=1');
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Rollback Transaction
+ *
+ * @access public
+ * @return bool
+ */
+ function trans_rollback()
+ {
+ if ( ! $this->trans_enabled)
+ {
+ return TRUE;
+ }
+
+ // When transactions are nested we only begin/commit/rollback the outermost ones
+ if ($this->_trans_depth > 0)
+ {
+ return TRUE;
+ }
+
+ $this->simple_query('ROLLBACK');
+ $this->simple_query('SET AUTOCOMMIT=1');
+ return TRUE;
+ }
+
// --------------------------------------------------------------------
/**
diff --git a/system/drivers/DB_oci8.php b/system/drivers/DB_oci8.php
index 06426dc..2f936da 100644
--- a/system/drivers/DB_oci8.php
+++ b/system/drivers/DB_oci8.php
@@ -43,6 +43,9 @@
class CI_DB_oci8 extends CI_DB {
+ // Set "auto commit" by default
+ var $_commit = OCI_COMMIT_ON_SUCCESS;
+
// need to track statement id and cursor id
var $stmt_id;
var $curs_id;
@@ -50,7 +53,7 @@
// if we use a limit, we will add a field that will
// throw off num_fields later
var $limit_used;
-
+
/**
* Non-persistent database connection
*
@@ -97,7 +100,7 @@
* @param string an SQL query
* @return resource
*/
- function execute($sql)
+ function _execute($sql)
{
// oracle must parse the query before it
// is run, all of the actions with
@@ -105,7 +108,7 @@
// returned by ociparse
$this->_set_stmt_id($sql);
ocisetprefetch($this->stmt_id, 1000);
- return @ociexecute($this->stmt_id);
+ return @ociexecute($this->stmt_id, $this->_commit);
}
/**
@@ -234,6 +237,83 @@
}
}
+ // --------------------------------------------------------------------
+
+ /**
+ * Begin Transaction
+ *
+ * @access public
+ * @return bool
+ */
+ function trans_begin()
+ {
+ if ( ! $this->trans_enabled)
+ {
+ return TRUE;
+ }
+
+ // When transactions are nested we only begin/commit/rollback the outermost ones
+ if ($this->_trans_depth > 0)
+ {
+ return TRUE;
+ }
+
+ $this->_commit = OCI_DEFAULT;
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Commit Transaction
+ *
+ * @access public
+ * @return bool
+ */
+ function trans_commit()
+ {
+ if ( ! $this->trans_enabled)
+ {
+ return TRUE;
+ }
+
+ // When transactions are nested we only begin/commit/rollback the outermost ones
+ if ($this->_trans_depth > 0)
+ {
+ return TRUE;
+ }
+
+ $ret = OCIcommit($this->conn_id);
+ $this->_commit = OCI_COMMIT_ON_SUCCESS;
+ return $ret;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Rollback Transaction
+ *
+ * @access public
+ * @return bool
+ */
+ function trans_rollback()
+ {
+ if ( ! $this->trans_enabled)
+ {
+ return TRUE;
+ }
+
+ // When transactions are nested we only begin/commit/rollback the outermost ones
+ if ($this->_trans_depth > 0)
+ {
+ return TRUE;
+ }
+
+ $ret = OCIrollback($this->conn_id);
+ $this->_commit = OCI_COMMIT_ON_SUCCESS;
+ return $ret;
+ }
+
// --------------------------------------------------------------------
/**
diff --git a/system/drivers/DB_odbc.php b/system/drivers/DB_odbc.php
index 57cdbce..a32e9e0 100644
--- a/system/drivers/DB_odbc.php
+++ b/system/drivers/DB_odbc.php
@@ -77,7 +77,7 @@
* @param string an SQL query
* @return resource
*/
- function execute($sql)
+ function _execute($sql)
{
$sql = $this->_prep_query($sql);
return @odbc_exec($this->conn_id, $sql);
@@ -98,7 +98,83 @@
{
return $sql;
}
-
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Begin Transaction
+ *
+ * @access public
+ * @return bool
+ */
+ function trans_begin()
+ {
+ if ( ! $this->trans_enabled)
+ {
+ return TRUE;
+ }
+
+ // When transactions are nested we only begin/commit/rollback the outermost ones
+ if ($this->_trans_depth > 0)
+ {
+ return TRUE;
+ }
+
+ return odbc_autocommit($this->conn_id, FALSE);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Commit Transaction
+ *
+ * @access public
+ * @return bool
+ */
+ function trans_commit()
+ {
+ if ( ! $this->trans_enabled)
+ {
+ return TRUE;
+ }
+
+ // When transactions are nested we only begin/commit/rollback the outermost ones
+ if ($this->_trans_depth > 0)
+ {
+ return TRUE;
+ }
+
+ $ret = odbc_commit($this->conn_id);
+ odbc_autocommit($this->conn_id, TRUE);
+ return $ret;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Rollback Transaction
+ *
+ * @access public
+ * @return bool
+ */
+ function trans_rollback()
+ {
+ if ( ! $this->trans_enabled)
+ {
+ return TRUE;
+ }
+
+ // When transactions are nested we only begin/commit/rollback the outermost ones
+ if ($this->_trans_depth > 0)
+ {
+ return TRUE;
+ }
+
+ $ret = odbc_rollback($this->conn_id);
+ odbc_autocommit($this->conn_id, TRUE);
+ return $ret;
+ }
+
// --------------------------------------------------------------------
/**
diff --git a/system/drivers/DB_postgre.php b/system/drivers/DB_postgre.php
index 57ef179..fe7c704 100644
--- a/system/drivers/DB_postgre.php
+++ b/system/drivers/DB_postgre.php
@@ -81,7 +81,7 @@
* @param string an SQL query
* @return resource
*/
- function execute($sql)
+ function _execute($sql)
{
$sql = $this->_prep_query($sql);
return @pg_query($this->conn_id, $sql);
@@ -102,7 +102,79 @@
{
return $sql;
}
-
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Begin Transaction
+ *
+ * @access public
+ * @return bool
+ */
+ function trans_begin()
+ {
+ if ( ! $this->trans_enabled)
+ {
+ return TRUE;
+ }
+
+ // When transactions are nested we only begin/commit/rollback the outermost ones
+ if ($this->_trans_depth > 0)
+ {
+ return TRUE;
+ }
+
+ return @pg_exec($this->conn_id, "begin");
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Commit Transaction
+ *
+ * @access public
+ * @return bool
+ */
+ function trans_commit()
+ {
+ if ( ! $this->trans_enabled)
+ {
+ return TRUE;
+ }
+
+ // When transactions are nested we only begin/commit/rollback the outermost ones
+ if ($this->_trans_depth > 0)
+ {
+ return TRUE;
+ }
+
+ return @pg_exec($this->conn_id, "commit");
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Rollback Transaction
+ *
+ * @access public
+ * @return bool
+ */
+ function trans_rollback()
+ {
+ if ( ! $this->trans_enabled)
+ {
+ return TRUE;
+ }
+
+ // When transactions are nested we only begin/commit/rollback the outermost ones
+ if ($this->_trans_depth > 0)
+ {
+ return TRUE;
+ }
+
+ return @pg_exec($this->conn_id, "rollback");
+ }
+
// --------------------------------------------------------------------
/**
diff --git a/system/drivers/DB_sqlite.php b/system/drivers/DB_sqlite.php
index 48e2c87..6d7b429 100644
--- a/system/drivers/DB_sqlite.php
+++ b/system/drivers/DB_sqlite.php
@@ -98,7 +98,7 @@
* @param string an SQL query
* @return resource
*/
- function execute($sql)
+ function _execute($sql)
{
$sql = $this->_prep_query($sql);
return @sqlite_query($this->conn_id, $sql);
@@ -119,6 +119,81 @@
{
return $sql;
}
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Begin Transaction
+ *
+ * @access public
+ * @return bool
+ */
+ function trans_begin()
+ {
+ if ( ! $this->trans_enabled)
+ {
+ return TRUE;
+ }
+
+ // When transactions are nested we only begin/commit/rollback the outermost ones
+ if ($this->_trans_depth > 0)
+ {
+ return TRUE;
+ }
+
+ $this->simple_query('BEGIN TRANSACTION');
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Commit Transaction
+ *
+ * @access public
+ * @return bool
+ */
+ function trans_commit()
+ {
+ if ( ! $this->trans_enabled)
+ {
+ return TRUE;
+ }
+
+ // When transactions are nested we only begin/commit/rollback the outermost ones
+ if ($this->_trans_depth > 0)
+ {
+ return TRUE;
+ }
+
+ $this->simple_query('COMMIT');
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Rollback Transaction
+ *
+ * @access public
+ * @return bool
+ */
+ function trans_rollback()
+ {
+ if ( ! $this->trans_enabled)
+ {
+ return TRUE;
+ }
+
+ // When transactions are nested we only begin/commit/rollback the outermost ones
+ if ($this->_trans_depth > 0)
+ {
+ return TRUE;
+ }
+
+ $this->simple_query('ROLLBACK');
+ return TRUE;
+ }
// --------------------------------------------------------------------