@@ -224,7 +224,14 @@ you can access it using the ``getConnection()`` method and the name of the conne
224
224
Disable Autocommit Mode
225
225
~~~~~~~~~~~~~~~~~~~~~~~
226
226
227
- To disable the `Autocommit `_ mode, update your DBAL configuration as follows:
227
+ By default, `autocommit `_ is enabled when using Doctrine DBAL. This means that
228
+ each ``INSERT ``, ``UPDATE ``, or ``DELETE `` statement is immediately committed
229
+ after it runs. You don't need to call ``commit() `` or ``rollback() `` because
230
+ there's no open transaction.
231
+
232
+ You can disable autocommit to keep the connection inside a transaction until
233
+ you explicitly call ``$connection->commit() `` or ``$connection->rollBack() ``.
234
+ Here's how to disable autocommit mode in DBAL:
228
235
229
236
.. configuration-block ::
230
237
@@ -235,10 +242,10 @@ To disable the `Autocommit`_ mode, update your DBAL configuration as follows:
235
242
connections :
236
243
default :
237
244
options :
238
- # Only if you're using DBAL with PDO:
245
+ # add this only if you're using DBAL with PDO:
239
246
!php/const PDO::ATTR_AUTOCOMMIT: false
240
247
241
- # This line disables auto-commit at the DBAL level:
248
+ # this option disables auto-commit at the DBAL level:
242
249
auto_commit : false
243
250
244
251
.. code-block :: xml
@@ -256,15 +263,16 @@ To disable the `Autocommit`_ mode, update your DBAL configuration as follows:
256
263
<doctrine : dbal
257
264
auto-commit =" false"
258
265
>
259
- <!-- Only if you are using DBAL with PDO -->
266
+ <!-- add this only if you are using DBAL with PDO -->
260
267
<doctrine : connection name =" default" >
261
268
<doctrine : option key-type =" constant" key =" PDO::ATTR_AUTOCOMMIT" >false</doctrine : option >
262
269
</doctrine : connection >
263
270
</doctrine : dbal >
264
271
</doctrine : config >
265
272
</container >
266
273
267
- When using the `Doctrine Migrations Bundle `_, an additional listener needs to be registered to ensure that the last migration is properly committed:
274
+ When using the `Doctrine Migrations Bundle `_, you need to register an additional
275
+ listener to ensure that the final migration is committed properly:
268
276
269
277
.. configuration-block ::
270
278
@@ -753,7 +761,7 @@ Ensure your environment variables are correctly set in the ``.env.local`` or
753
761
754
762
This configuration secures your MySQL connection with SSL by specifying the paths to the required certificates.
755
763
756
- .. _ Autocommit : https://en.wikipedia.org/wiki/Autocommit
757
- .. _ Doctrine Migrations Bundle : https://github.com/doctrine/DoctrineMigrationsBundle
758
- .. _ DBAL documentation : https://www.doctrine-project.org/projects/doctrine-dbal/en/current/reference/configuration.html
764
+ .. _ `autocommit` : https://en.wikipedia.org/wiki/Autocommit
765
+ .. _ `Doctrine Migrations Bundle` : https://github.com/doctrine/DoctrineMigrationsBundle
766
+ .. _ `DBAL documentation` : https://www.doctrine-project.org/projects/doctrine-dbal/en/current/reference/configuration.html
759
767
.. _`Doctrine Metadata Drivers` : https://www.doctrine-project.org/projects/doctrine-orm/en/current/reference/metadata-drivers.html
0 commit comments