开发者

how to update yml created entities, if they are expanded with business logic?

when you execute doctrine:generate:entities with a set of yml files containing your relation mapping, all Entity classes are automatically generated.

When you adjust your yml files and regenerate the Entity classes, they are overwritten (and the old ones are backed up).

In do开发者_运维问答ctrine1, the entity-generator created Base Classes that where automatically inherited by the actual Entity Class, that you could expand with your own business logic.

In doctrine2 I don't see those base classes, and I don't want to adjust my generated classes, because i won't be able to update my datamodel in my yml files.

What is the Doctrine2 approach? Should i manually inherit from my generated Entity Classes to add business logic? Can doctrine adjust the Entity class, and keeping the additional changes (with some sort of diffing algorithm)? Does the entity-generation only be used once to generate the classes, and should all the datamodel changes be implemented manually in the Class itself?


In Doctrine2 you program your entities as you wish (with respective fields, getters and setters, custom business logic, etc.), and then create the yaml (or xml, annotations, etc.) mappings. What Doctrine2 then generates are the DB tables which correspond to your mappings, so your entities are always preserved.

I suggest you take a look at the Doctrine2 Quick Start Guide, it will give a pretty good idea of the Doctrine2 ORM approach.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜