php - Symfony2/Doctrine: Reuse Unique base Entity for inheritance entities -
in software have 3 entities: person, teacher , examiner next structure:
<?php class person { protected $id; protected $firstname; protected $lastname; } class teacher extends person { protected $subjects; } class examiner extends person { protected $certificates; } here problem: planned utilize joined class table inheritance , person unique entity. reuse examiner teacher. have two diffrent entities examiner , teacher, one base of operations entity person both of them.
in example:
person | id | firstname | lastname | 1 | emile | illustration teacher | id | subjects | 1 | math, religion, english language <--- inheritance of person id 1 examiner | id | certificate | 1 | bachelor of science <--- inheritance of person id 1, is there possibility accomplish doctrine annotations? dont thought of having entity person relation of both explicit classes. prefere reproduce real world szenario, e.g. teacher not have person rather person.
hope got thought achieve.
thanks!
i guess should declare abstract mappedsuperclass "human" instance holds mutual attributes , methods. won't persisted in database.
then declare person, teacher , examiner inherit human , declare own specific attributes , methods. that's concrete tables stored in database.
this should help: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/inheritance-mapping.html
regards.
php symfony2 doctrine2 entity
No comments:
Post a Comment