Doctrine 的事件监听类中的 postUpdate 和 postPersist 事件有什么区别?以我的理解,更新和插入都必须坚持下去。那么当可以在 postPersist 事件中处理它时,拥有 postUpdate 有什么好处?
最佳答案
因为您应该只在更新时处理一些逻辑。 从学说的文档中:
postPersist - The postPersist event occurs for an entity after the entity has been made persistent. It will be invoked after the database insert operations. Generated primary key values are available in the postPersist event.
postUpdate - The postUpdate event occurs after the database update operations to entity data. It is not called for a DQL UPDATE statement.
你现在看出区别了吗? postPersist
事件仅在 INSERT
操作后启动。
关于php - postUpdate 和 postPersist 在学说上的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25178357/