cleaning up and formatting database pages
diff --git a/user_guide_src/source/database/transactions.rst b/user_guide_src/source/database/transactions.rst
index e82210b..e9190e5 100644
--- a/user_guide_src/source/database/transactions.rst
+++ b/user_guide_src/source/database/transactions.rst
@@ -35,7 +35,11 @@
$this->db->trans_start() and $this->db->trans_complete() functions as
follows::
- $this->db->trans_start(); $this->db->query('AN SQL QUERY...'); $this->db->query('ANOTHER QUERY...'); $this->db->query('AND YET ANOTHER QUERY...'); $this->db->trans_complete();
+ $this->db->trans_start();
+ $this->db->query('AN SQL QUERY...');
+ $this->db->query('ANOTHER QUERY...');
+ $this->db->query('AND YET ANOTHER QUERY...');
+ $this->db->trans_complete();
You can run as many queries as you want between the start/complete
functions and they will all be committed or rolled back based on success
@@ -61,7 +65,15 @@
you'll see a standard error message if the commit was unsuccessful. If
debugging is turned off, you can 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) { // generate an error... or use the log_message() function to log your error }
+ $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)
+ {
+ // generate an error... or use the log_message() function to log your error
+ }
Enabling Transactions
=====================
@@ -70,7 +82,11 @@
$this->db->trans_start(). If you would like to disable transactions you
can do so using $this->db->trans_off()::
- $this->db->trans_off() $this->db->trans_start(); $this->db->query('AN SQL QUERY...'); $this->db->trans_complete();
+ $this->db->trans_off();
+
+ $this->db->trans_start();
+ $this->db->query('AN SQL QUERY...');
+ $this->db->trans_complete();
When transactions are disabled, your queries will be auto-commited, just
as they are when running queries without transactions.
@@ -83,14 +99,29 @@
a valid result. To use test mode simply set the first parameter in the
$this->db->trans_start() function to TRUE::
- $this->db->trans_start(TRUE); // Query will be rolled back $this->db->query('AN SQL QUERY...'); $this->db->trans_complete();
+ $this->db->trans_start(TRUE); // Query will be rolled back
+ $this->db->query('AN SQL QUERY...');
+ $this->db->trans_complete();
Running Transactions Manually
=============================
If you would like to run transactions manually you can do so as follows::
- $this->db->trans_begin(); $this->db->query('AN SQL QUERY...'); $this->db->query('ANOTHER QUERY...'); $this->db->query('AND YET ANOTHER QUERY...'); if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); } else { $this->db->trans_commit(); }
+ $this->db->trans_begin();
+
+ $this->db->query('AN SQL QUERY...');
+ $this->db->query('ANOTHER QUERY...');
+ $this->db->query('AND YET ANOTHER QUERY...');
+
+ if ($this->db->trans_status() === FALSE)
+ {
+ $this->db->trans_rollback();
+ }
+ else
+ {
+ $this->db->trans_commit();
+ }
.. note:: Make sure to use $this->db->trans_begin() when running manual
transactions, **NOT** $this->db->trans_start().