summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoradmin <devnull@localhost>2006-09-23 21:58:47 +0200
committeradmin <devnull@localhost>2006-09-23 21:58:47 +0200
commitf5ea6653153ea8e78f347b7a552ff9049cc47caf (patch)
tree77857deda7deff2741659b95bbc5902c87518db2
parentb5a651cd710f7454425b9b94ff4a44fc4edacaba (diff)
-rw-r--r--system/drivers/DB_mysql.php80
1 files changed, 79 insertions, 1 deletions
diff --git a/system/drivers/DB_mysql.php b/system/drivers/DB_mysql.php
index 72790976e..69a6db0eb 100644
--- a/system/drivers/DB_mysql.php
+++ b/system/drivers/DB_mysql.php
@@ -83,7 +83,7 @@ class CI_DB_mysql extends CI_DB {
* @param string an SQL query
* @return resource
*/
- function execute($sql)
+ function _execute($sql)
{
$sql = $this->_prep_query($sql);
return @mysql_query($sql, $this->conn_id);
@@ -114,6 +114,84 @@ class CI_DB_mysql 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;
+ }
// --------------------------------------------------------------------