Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[DoctrineBundle] Add infos about disabling the Autocommit mode#20824

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Crovitche-1623 wants to merge7 commits intosymfony:7.2
base:7.2
Choose a base branch
Loading
fromCrovitche-1623:patch-1
Open
Changes fromall 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
93 changes: 92 additions & 1 deletionreference/configuration/doctrine.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -166,6 +166,96 @@
}
}

Disable Autocommit Mode
~~~~~~~~~~~~~~~~~~~~~~~

To disable the `Autocommit`_ mode, update your DBAL configuration as follows:

.. configuration-block::

.. code-block:: yaml

doctrine:
dbal:
connections:
default:
options:
# Only if you're using DBAL with PDO:
!php/const PDO::ATTR_AUTOCOMMIT: false

# This line disables auto-commit at the DBAL level:
auto_commit: false

.. code-block:: xml

<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:doctrine="http://symfony.com/schema/dic/doctrine"
xmlns="http://symfony.com/schema/dic/services"
xsi:schemaLocation="http://symfony.com/schema/dic/services
https://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/doctrine
https://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">

<doctrine:config>
<doctrine:dbal
auto-commit="false"
>
<!-- Only if you are using DBAL with PDO -->
<doctrine:connection name="default">
<doctrine:option key-type="constant" key="PDO::ATTR_AUTOCOMMIT">false</doctrine:option>
</doctrine:connection>
</doctrine:dbal>
</doctrine:config>
</container>

When using the `Doctrine Migrations Bundle`_, an additional listener needs to be registered to ensure that the last migration is properly committed:

.. configuration-block::

.. code-block:: yaml

# config/services.yaml
services:
Doctrine\Migrations\Event\Listeners\AutoCommitListener:
tags:
- name: doctrine.event_listener
event: onMigrationsMigrated

.. code-block:: xml

<!-- config/services.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services
https://symfony.com/schema/dic/services/services-1.0.xsd">

<services>
<service id="Doctrine\Migrations\Event\Listeners\AutoCommitListener">
<tag name="doctrine.event_listener" event="onMigrationsMigrated"/>
</service>
</services>
</container>

.. code-block:: php

// config/services.php
namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use Doctrine\Migrations\Event\Listeners\AutoCommitListener;

Check failure on line 246 in reference/configuration/doctrine.rst

View workflow job for this annotation

GitHub Actions/ Code Blocks

[Missing class] Class, interface or trait with name "Doctrine\Migrations\Event\Listeners\AutoCommitListener" does not exist
use Doctrine\Migrations\Events;

Check failure on line 247 in reference/configuration/doctrine.rst

View workflow job for this annotation

GitHub Actions/ Code Blocks

[Missing class] Class, interface or trait with name "Doctrine\Migrations\Events" does not exist

return function(ContainerConfigurator $container): void {
$services = $container->services();

$services->set(AutoCommitListener::class)
->tag('doctrine.event_listener', [
'event' => Events::onMigrationsMigrated
])
;
};

Doctrine ORM Configuration
--------------------------

Expand DownExpand Up@@ -544,6 +634,7 @@

This configuration secures your MySQL connection with SSL by specifying the paths to the required certificates.


.. _Autocommit: https://en.wikipedia.org/wiki/Autocommit
.. _Doctrine Migrations Bundle: https://github.com/doctrine/DoctrineMigrationsBundle
.. _DBAL documentation: https://www.doctrine-project.org/projects/doctrine-dbal/en/current/reference/configuration.html
.. _`Doctrine Metadata Drivers`: https://www.doctrine-project.org/projects/doctrine-orm/en/current/reference/metadata-drivers.html
Loading

[8]ページ先頭

©2009-2025 Movatter.jp