@@ -224,7 +224,14 @@ you can access it using the ``getConnection()`` method and the name of the conne
224224Disable Autocommit Mode
225225~~~~~~~~~~~~~~~~~~~~~~~
226226
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:
228235
229236.. configuration-block ::
230237
@@ -235,10 +242,10 @@ To disable the `Autocommit`_ mode, update your DBAL configuration as follows:
235242 connections :
236243 default :
237244 options :
238- # Only if you're using DBAL with PDO:
245+ # add this only if you're using DBAL with PDO:
239246 !php/const PDO::ATTR_AUTOCOMMIT: false
240247
241- # This line disables auto-commit at the DBAL level:
248+ # this option disables auto-commit at the DBAL level:
242249 auto_commit : false
243250
244251 .. code-block :: xml
@@ -256,15 +263,16 @@ To disable the `Autocommit`_ mode, update your DBAL configuration as follows:
256263 <doctrine : dbal
257264 auto-commit =" false"
258265 >
259- <!-- Only if you are using DBAL with PDO -->
266+ <!-- add this only if you are using DBAL with PDO -->
260267 <doctrine : connection name =" default" >
261268 <doctrine : option key-type =" constant" key =" PDO::ATTR_AUTOCOMMIT" >false</doctrine : option >
262269 </doctrine : connection >
263270 </doctrine : dbal >
264271 </doctrine : config >
265272 </container >
266273
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:
268276
269277.. configuration-block ::
270278
@@ -753,7 +761,7 @@ Ensure your environment variables are correctly set in the ``.env.local`` or
753761
754762 This configuration secures your MySQL connection with SSL by specifying the paths to the required certificates.
755763
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
759767.. _`Doctrine Metadata Drivers` : https://www.doctrine-project.org/projects/doctrine-orm/en/current/reference/metadata-drivers.html
0 commit comments