当一个特殊领域发生变化时做一些事情(主义) [英] Do something when one special field changes (doctrine)

查看:59
本文介绍了当一个特殊领域发生变化时做一些事情(主义)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将symfony2与理论结合使用.当实体的特殊属性更改时,我想做一些更改.实际上,我想保存属性的更改并具有更改状态.例如,当任何字段更改发生与更改的字段名称相关的事情时,我怎么说?

I use symfony2 with doctrine. I want to do some changes when special attributes of an entity changes; actually I want to save the changes of my attributes and have an status of it's changes. How can i say for example when any field changes do something relevant to the changed field's name.

例如,如果电子邮件发生更改,请在其他实体中添加一些行.

for example if email changed, add some row to the other entity.

谢谢.

推荐答案

除了Yan的答案,Doctrine已经提供了满足您需求的方法,例如 hasChangedField getNewValue .您可以在这里阅读更多内容:

As addition to Yan answer, Doctrine already has methods for your needs like hasChangedField, getNewValue.. You can read more here:

http://doctrine-orm.readthedocs.org/zh_CN/latest/reference/events.html#preupdate

这篇关于当一个特殊领域发生变化时做一些事情(主义)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆