mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Docs: EntityManager::transactional vs Connection::transactional #6095
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ghost on GitHub (Nov 1, 2018).
https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/transactions-and-concurrency.html#approach-2-explicitly in "Approach 2: Explicitly" the first way (with beginTransaction()) when catching the exception does not close the entity manager, whereas the second way (with transactional(), see \Doctrine\ORM\EntityManager::transactional) does close the entity manager when an exception occurs. So these two peaces of code are not equivalent as stated. I think it should be $em->getConnection()->transactional() (which does not close the EntityManager) instead of $em->transactional().
@anilex commented on GitHub (Apr 7, 2020):
There is a reason for resetting the EM.
Here is a more detailed explanation.