Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I would like to extend EntityBase classes, how to do this in Doctrine 2.1? My research showed that whenever someone encounters the problem with doing this he switches to Doctrine 1.2 :)n I am using yaml configuration

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
746 views
Welcome To Ask or Share your Answers For Others

1 Answer

Doctrine 2.X Entities work as POPOs (Plain Old PHP Objects). To achieve extending correctly, Doctrine enforces you to use a concept from JPA called Mapped Super Classes. The idea is pretty simple. Whenever you want to have a base class and want your entities to extend from it (I'm not talking about inheritance at DB level), all you need to do is create your Base class as a MappedSuperClass.

Here is an example: http://www.doctrine-project.org/docs/orm/2.1/en/reference/inheritance-mapping.html#mapped-superclasses

Thanks


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...