mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-877: Auto Flush pending transactions at destruct time #1088
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 @doctrinebot on GitHub (Nov 16, 2010).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user nd987:
It would be great if Doctrine would auto flush pending transactions at the end of script execution. This would make the coder's life that much easier, as they don't have to remember to flush() somewhere after they are done making changes...they just call persist() as needed, knowing that if they don't explicitly flush(), it will automatically happen.
Explicitly flush()-ing would still be supported and even encouraged. The Entity Manager's **destruct() function simply has to check for pending transactions, flush()-ing any it finds.
@doctrinebot commented on GitHub (Nov 16, 2010):
Comment created by @beberlei:
No, the explicitlyness of flush is very important. If you have a read only request with lots of objects flush is going to cost a huge bunch of performance.
@doctrinebot commented on GitHub (Nov 16, 2010):
Issue was closed with resolution "Won't Fix"
@doctrinebot commented on GitHub (Nov 17, 2010):
Comment created by nd987:
Ah, I had assumed that Doctrine kept track of whether or not anything needed to be flushed, so that calling flush() when no changes had been made was an inexpensive operation and did not loop over every object. In a read only request, persist() would have never been called and hence no flush required...so inside the flush() method, a simple check like needsFlush() could prevent a loop over all objects.
@doctrinebot commented on GitHub (Nov 18, 2010):
Comment created by @beberlei:
No, by default you don't have to call ->persist() for entities that changed at all. Only for new ones.
Doctrine knows the entities that have been retrieved from the database and upon flush it iterates through all of them and tries to detect changes.