Skip to content

Commit fb5e3e7

Browse files
committed
docs: update docs
1 parent 18aa080 commit fb5e3e7

File tree

6 files changed

+12
-38
lines changed

6 files changed

+12
-38
lines changed

user_guide_src/source/changelogs/v4.3.0.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Exceptions when Database Errors Occur
2727

2828
- The exceptions thrown by the database connection classes have been changed to ``CodeIgniter\Database\Exceptions\DatabaseException``. Previously, different database drivers threw different exception classes, but these have been unified into ``DatabaseException``.
2929
- The exceptions thrown by the ``execute()`` method of Prepared Queries have been changed to ``DatabaseException``. Previously, different database drivers might throw different exception classes or did not throw exceptions, but these have been unified into ``DatabaseException``.
30+
- During transactions, exceptions are not thrown by default even if ``DBDebug`` is true.
3031
- ``DBDebug`` and ``CI_DEBUG`` Changes
3132

3233
- To be consistent in behavior regardless of environments, ``Config\Database::$default['DBDebug']``
@@ -38,11 +39,10 @@ Exceptions when Database Errors Occur
3839
- The default value of ``BaseConnection::$DBDebug`` has been changed to ``true``.
3940
- With these changes, ``DBDebug`` **now means whether or not to throw an exception when an error occurs**.
4041
Although unrelated to debugging, the name has not been changed.
41-
- When running transactions with ``DBDebug`` is ``true``, if a query error occurs, all the queries
42-
will be rolled backed, and an exception will be thrown. :ref:`transactions-managing-errors` or
43-
:ref:`transactions-manual-transactions` won't work. This is no different from previous versions,
44-
but changing the ``DBDebug`` setting from the previous default value to ``true`` will change the
45-
behavior in the production environment.
42+
- When running transactions with ``DBDebug`` is ``true``, even if a query error occurs, exceptions
43+
are not thrown by default. Previously, if a query error occurs, all the queries
44+
will be rolled backed, and an exception will be thrown, so :ref:`transactions-managing-errors` or
45+
:ref:`transactions-manual-transactions` won't work.
4646
- Now when you delete without WHERE clause in ``Model``, ``DatabaseException`` is thrown even if
4747
``CI_DEBUG`` is false. Previously, it is thrown if ``CI_DEBUG`` is true.
4848

user_guide_src/source/database/transactions.rst

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,9 @@ contrast, we've implemented a smart transaction system that does all
3232
this for you automatically (you can also manage your transactions
3333
manually if you choose to, but there's really no benefit).
3434

35-
.. note:: Since v4.3.0, ``DBDebug`` is true by default in all environments.
36-
When ``DBDebug`` is true, if a query error occurs, all the queries
37-
will be rolled backed, and a ``DatabaseException`` will be thrown.
38-
In previous versions, ``DBDebug`` was false only in production environment,
39-
and different database drivers might throw different exception classes.
35+
.. note::
36+
Since v4.3.0, during transactions, exceptions are not thrown by default
37+
even if ``DBDebug`` is true.
4038

4139
Running Transactions
4240
====================
@@ -45,8 +43,6 @@ To run your queries using transactions you will use the
4543
``$this->db->transStart()`` and ``$this->db->transComplete()`` functions as
4644
follows:
4745

48-
.. literalinclude:: transactions/008.php
49-
5046
.. literalinclude:: transactions/001.php
5147

5248
You can run as many queries as you want between the start/complete
@@ -66,30 +62,15 @@ Strict Mode can be disabled as follows:
6662

6763
.. literalinclude:: transactions/002.php
6864

69-
.. note:: Since v4.3.0, ``DBDebug`` is true by default in all environments.
70-
When ``DBDebug`` is true, if a query error occurs, all the queries
71-
will be rolled backed, and a ``DatabaseException`` will be thrown.
72-
In previous versions, ``DBDebug`` was false only in production environment,
73-
and different database drivers might throw different exception classes.
74-
7565
.. _transactions-managing-errors:
7666

7767
Managing Errors
7868
===============
7969

80-
If you have ``DBDebug`` true in your **app/Config/Database.php** file
81-
you'll see a ``DatabaseException`` thrown if a query error occurs.
82-
83-
If ``DBDebug`` is false, you can manage your own errors like this:
70+
You can manage your own errors like this:
8471

8572
.. literalinclude:: transactions/003.php
8673

87-
.. note:: Since v4.3.0, ``DBDebug`` is true by default in all environments.
88-
When ``DBDebug`` is true, if a query error occurs, all the queries
89-
will be rolled backed, and a ``DatabaseException`` will be thrown.
90-
In previous versions, ``DBDebug`` was false only in production environment,
91-
and different database drivers might throw different exception classes.
92-
9374
Disabling Transactions
9475
======================
9576

@@ -116,8 +97,7 @@ a valid result. To use test mode simply set the first parameter in the
11697
Running Transactions Manually
11798
=============================
11899

119-
If you have ``DBDebug`` false in your **app/Config/Database.php** file
120-
and if you would like to run transactions manually you can do so as follows:
100+
If you would like to run transactions manually you can do so as follows:
121101

122102
.. literalinclude:: transactions/006.php
123103

user_guide_src/source/database/transactions/001.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
// When DBDebug in the Database Config is false.
4-
53
$this->db->transStart();
64
$this->db->query('AN SQL QUERY...');
75
$this->db->query('ANOTHER QUERY...');

user_guide_src/source/database/transactions/003.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
// DBDebug in the Database Config must be false.
4-
53
$this->db->transStart();
64
$this->db->query('AN SQL QUERY...');
75
$this->db->query('ANOTHER QUERY...');

user_guide_src/source/database/transactions/006.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
// DBDebug in the Database Config must be false.
4-
53
$this->db->transBegin();
64

75
$this->db->query('AN SQL QUERY...');

user_guide_src/source/database/transactions/008.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
22

3-
// When DBDebug in the Database Config is true.
3+
// When DBDebug in the Database Config must be true.
44

55
use CodeIgniter\Database\Exceptions\DatabaseException;
66

77
try {
8-
$this->db->transStart();
8+
$this->db->transException(true)->transStart();
99
$this->db->query('AN SQL QUERY...');
1010
$this->db->query('ANOTHER QUERY...');
1111
$this->db->query('AND YET ANOTHER QUERY...');

0 commit comments

Comments
 (0)