From 7d8a3c7a5de132cd540b637753f10333694b9420 Mon Sep 17 00:00:00 2001 From: admin Date: Sun, 24 Sep 2006 01:12:07 +0000 Subject: --- user_guide/libraries/database/transactions.html | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'user_guide') diff --git a/user_guide/libraries/database/transactions.html b/user_guide/libraries/database/transactions.html index 41f27fc76..35e494282 100644 --- a/user_guide/libraries/database/transactions.html +++ b/user_guide/libraries/database/transactions.html @@ -66,18 +66,18 @@ Transactions

Transactions

-

Code Igniter's database abstraction allows you to use transactions will databases that support transaction-safe table types. In MySQL, you'll need +

Code Igniter's database abstraction allows you to use transactions with databases that support transaction-safe table types. In MySQL, you'll need to be running InnoDB or BDB table types rather then the more common MyISAM. Most other databases support transactions natively.

If you are not familiar with -transactions we recommend you spend some time learning about them for your particular database. The information below assumes you -have a basic understanding of transactions. +transactions we recommend you find a good online resource to learn about them for your particular database. The information below assumes you +have a basic understanding of transactions. For most sites, however, transactions won't be necessary.

Code Igniter's Approach to Transactions

-

Code Igniter utilizes an approach to transactions that is very similar to the popular database class ADODB. We've chosen that approach -becuase it greatly simplifies the process of running transactions. In most cases all that is required are two lines of code.

+

Code Igniter utilizes an approach to transactions that is very similar to the process used by the popular database class ADODB. We've chosen that approach +because it greatly simplifies the process of running transactions. In most cases all that is required are two lines of code.

Traditionally transactions have required a fair amount of work to implement since they demand that you to keep track of your queries and determine whether to commit or rollback based on the success or failure of your queries. In contrast, @@ -85,7 +85,7 @@ we've implemented a smart transaction system that does all this for you automati

Running Transactions

-

To run your queries using transactions you will use the $this->db->trans_start() and $this->db->trans_complete() functions as follows:

+

To run your queries using transactions you will use the $this->db->trans_start() and $this->db->trans_complete() functions as follows:

$this->db->trans_start();
@@ -106,6 +106,7 @@ manage your own errors like this:

$this->db->trans_start();
$this->db->query('AN SQL QUERY...');
+$this->db->query('ANOTHER QUERY...');
$this->db->trans_complete();

if ($this->db->trans_status() === FALSE)
@@ -117,8 +118,8 @@ if ($this->db->trans_status() === FALSE)

Enabling Transactions

-

Transactions are enabled automatically the moment you use $this->db->trans_start(). If you would like to disable transactions you -can do so using $this->db->trans_off(): +

Transactions are enabled automatically the moment you use $this->db->trans_start(). If you would like to disable transactions you +can do so using $this->db->trans_off(): $this->db->trans_off()

@@ -128,16 +129,16 @@ $this->db->query('AN SQL QUERY...');
$this->db->trans_complete();
-

When transactions are disabled, any queries will be auto-commited, just as they are when running queries normally.

+

When transactions are disabled, your queries will be auto-commited, just as they are when running queries without transactions.

Test Mode

You can optionally put the transaction system into "test mode", which will cause your queries to be rolled back -- even if the queries produce a valid result. -To use test mode simply set the first parameter in the $this->db->trans_start() function to TRUE: +To use test mode simply set the first parameter in the $this->db->trans_start() function to TRUE: -$this->db->trans_start(TRUE);
+$this->db->trans_start(TRUE); // Query will be rolled back
$this->db->query('AN SQL QUERY...');
$this->db->trans_complete();
@@ -166,7 +167,7 @@ else
}
-

Note: Make sure to use $this->db->trans_begin() when running manual trasactions, NOT +

Note: Make sure to use $this->db->trans_begin() when running manual transactions, NOT $this->db->trans_start().

-- cgit v1.2.3-24-g4f1b