when is the best "time" to flush the Entity/Object-manager? Should it be after every persist operation? Or should it be run once on e.g. postDispatch?
相关问题
- Why does recursive submodule update from github fa
- How to pass options/params to formCollection field
- Lifecycle Callback Issue When Extending FOSUserBun
- Compress html output from zend framework 2
- Doctrine 2.5: Unrecognized field (but only in Symf
相关文章
- Symfony : Doctrine data fixture : how to handle la
- Is there a way to modify the entity mapping config
- Get random records with Doctrine
- Doctrine not finding data on Google App Engine?
- Doctrine 2: Cannot select entity through identific
- Symfony does not remove entity from collection
- Symfony doctrine:schema:update not working
- Storing Doctrine2 DateTime in UTC Only
Ideally, once at the end of the request. But if you're working with too many entities, than it's better do flush soon as you can, and do not let the unit of work to be overloaded with entities. This is when things can get very weird, because the problem with the spl_object_hash doesnt identify all those objects with unicity.
Use the clear() too, as soon as you're done with some entities and will started with others.
Running it after every persist is an antipattern actually. Ideally, you should run it once at the end of the request.
I would not put it in a postDispatch handler, because that means it will run after every request, and that is going to be costly performance wise on, for example, list pages, where you list entities with many relations, because Doctrine will have to examine many entities for changes.
Put it at the end of actions that modify data.