summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
authoradmin <devnull@localhost>2006-09-23 22:25:05 +0200
committeradmin <devnull@localhost>2006-09-23 22:25:05 +0200
commite885d787cde65d9ab003426bf79047de57c83ebe (patch)
tree1421b7cca06f61b1b0274b238d6f9fbf39afd679 /system
parent66530a809018c2ba39d9adb5b2cf21640969e472 (diff)
Diffstat (limited to 'system')
-rw-r--r--system/drivers/DB_mssql.php77
-rw-r--r--system/drivers/DB_mysqli.php83
-rw-r--r--system/drivers/DB_oci8.php86
-rw-r--r--system/drivers/DB_odbc.php80
-rw-r--r--system/drivers/DB_postgre.php76
-rw-r--r--system/drivers/DB_sqlite.php77
-rw-r--r--system/language/english/db_lang.php2
-rw-r--r--system/libraries/Xmlrpcs.php2
8 files changed, 471 insertions, 12 deletions
diff --git a/system/drivers/DB_mssql.php b/system/drivers/DB_mssql.php
index c84247641..3fbfa6a3f 100644
--- a/system/drivers/DB_mssql.php
+++ b/system/drivers/DB_mssql.php
@@ -76,7 +76,7 @@ class CI_DB_mssql extends CI_DB {
* @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 @@ class CI_DB_mssql extends CI_DB {
{
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 4b9685799..a5237c832 100644
--- a/system/drivers/DB_mysqli.php
+++ b/system/drivers/DB_mysqli.php
@@ -85,7 +85,7 @@ class CI_DB_mysqli extends CI_DB {
* @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 @@ class CI_DB_mysqli extends CI_DB {
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 06426dcac..2f936da12 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 @@ class CI_DB_oci8 extends CI_DB {
// 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 @@ class CI_DB_oci8 extends CI_DB {
* @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 @@ class CI_DB_oci8 extends CI_DB {
// 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 @@ class CI_DB_oci8 extends CI_DB {
}
}
+ // --------------------------------------------------------------------
+
+ /**
+ * 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 57cdbced8..a32e9e072 100644
--- a/system/drivers/DB_odbc.php
+++ b/system/drivers/DB_odbc.php
@@ -77,7 +77,7 @@ class CI_DB_odbc extends CI_DB {
* @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 @@ class CI_DB_odbc extends CI_DB {
{
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 57ef179d9..fe7c704f9 100644
--- a/system/drivers/DB_postgre.php
+++ b/system/drivers/DB_postgre.php
@@ -81,7 +81,7 @@ class CI_DB_postgre extends CI_DB {
* @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 @@ class CI_DB_postgre extends CI_DB {
{
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 48e2c8714..6d7b4294a 100644
--- a/system/drivers/DB_sqlite.php
+++ b/system/drivers/DB_sqlite.php
@@ -98,7 +98,7 @@ class CI_DB_sqlite extends CI_DB {
* @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 @@ class CI_DB_sqlite extends CI_DB {
{
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;
+ }
// --------------------------------------------------------------------
diff --git a/system/language/english/db_lang.php b/system/language/english/db_lang.php
index b210b61ba..d51bb6dce 100644
--- a/system/language/english/db_lang.php
+++ b/system/language/english/db_lang.php
@@ -11,5 +11,7 @@ $lang['db_must_use_where'] = 'Updates are not allowed unless they contain a "whe
$lang['db_del_must_use_where'] = 'Deletes are not allowed unless they contain a "where" clause.';
$lang['db_field_param_missing'] = 'To fetch fields requires the name of the table as a parameter.';
$lang['db_unsupported_function'] = 'This feature is not available for the database you are using.';
+$lang['db_transaction_failure'] = 'Transaction failure: Rollback performed';
+
?> \ No newline at end of file
diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php
index eaec87a6d..0543c3b78 100644
--- a/system/libraries/Xmlrpcs.php
+++ b/system/libraries/Xmlrpcs.php
@@ -223,7 +223,7 @@ class CI_XML_RPC_Server extends CI_XML_RPC
// Executes the Method
//-------------------------------------
- function execute($m)
+ function _execute($m)
{
$methName = $m->method_name;