Skip to content

docs: fix transactions.rst #6919

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions user_guide_src/source/database/transactions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,21 @@ Running Transactions
====================

To run your queries using transactions you will use the
``$this->db->transStart()`` and ``$this->db->transComplete()`` functions as
``$this->db->transStart()`` and ``$this->db->transComplete()`` methods as
follows:

.. literalinclude:: transactions/001.php

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 the success
You can run as many queries as you want between the ``transStart()``/``transComplete()``
methods and they will all be committed or rolled back based on the success
or failure of any given query.

Strict Mode
===========

By default, CodeIgniter runs all transactions in Strict Mode. When strict
mode is enabled, if you are running multiple groups of transactions, if
one group fails all groups will be rolled back. If strict mode is
one group fails all subsequent groups will be rolled back. If strict mode is
disabled, each group is treated independently, meaning a failure of one
group will not affect any others.

Expand All @@ -61,9 +61,11 @@ Strict Mode can be disabled as follows:
Managing Errors
===============

If you have error reporting enabled in your Config/Database.php file
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:
When you have ``DBDebug`` true in your **app/Config/Database.php** file,
if a query error occurs, all the queries will be rolled backed, and an exception
will be thrown. So you'll see a standard error page.

If the ``DBDebug`` is false, you can manage your own errors like this:

.. literalinclude:: transactions/003.php

Expand All @@ -84,14 +86,15 @@ 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->transStart()`` function to true:
``$this->db->transStart()`` method to true:

.. literalinclude:: transactions/005.php

Running Transactions Manually
=============================

If you would like to run transactions manually you can do so as follows:
When you have ``DBDebug`` false in your **app/Config/Database.php** file, and
if you would like to run transactions manually you can do so as follows:

.. literalinclude:: transactions/006.php

Expand Down