Doctrine2中的动态字段/属性 - 怎么样? [英] Dynamic fields/properties in Doctrine2 - how?
本文介绍了Doctrine2中的动态字段/属性 - 怎么样?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
一个解决方案是为喜欢创建一个单独的表和模型。但是,如果要显示喜欢的内容,则需要连接或其他选择。
解决方案
您是否尝试复制实体(不是模型)?
如果是这样,我建议您实现自己的行为,使用内置事件系统。
FYI:实体和模型之间的差异
I I would like plugins to be able to add properties to my models. For example, I have a model "Message". A "Like" plugin can add property "likedtimes" to it and maintain it. How can I get such functionality?
One solution is to create a separate table and model for likes. But that would require a join or additional select whenever likes are to be displayed.
解决方案
Are you trying to replicate common functionality between Entities (not models)?
If so, I would recommend you implement your own behavior, using the built-in event system.
FYI: Difference between entities and models
这篇关于Doctrine2中的动态字段/属性 - 怎么样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文