php - postUpdate 和 postPersist 在学说上的区别

标签 php database symfony doctrine-orm event-handling

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/

相关文章:

python - Flask peewee 无法在网络服务器上工作

mysql - 学说多次刷新提交一次

php - 使用 MySQL LIMIT、OFFSET 进行分页

sql - 使用 JOIN 而不是 INTERSECT 查询

PHP Static v Singleton 类 - ConnectionFactory 解释

php - MySQL 撇号-如何使用 MATCH/AGAINST 转义并返回正确的结果

Symfony2 DQL 如何连接 OneToMany 关系中的最后一行

javascript - Symfony2 和 AJAX

php - 在Openshift环境中,如何访问不同应用程序中的数据库?

php - 在 Woocommerce 中获取产品名称