【发布时间】:2014-06-18 11:42:25
【问题描述】:
在我的软件中,我有三个实体:Person、Teacher 和 Examiner,结构如下:
<?php
class Person
{
protected $id;
protected $firstname;
protected $lastname;
}
class Teacher extends Person
{
protected $subjects;
}
class Examiner extends Person
{
protected $certificates;
}
这是我的问题:我计划使用 JOINED Class Table 进行继承,我希望 Person 成为一个独特的实体。但我也想为 Examiner 和 Teacher 重用它。所以我有 两个不同的实体 Examiner 和 Teacher,但 他们都有一个基本实体人。
例如:
Person | id | firstname | lastname
| 1 | Emile | Example
Teacher | id | subjects
| 1 | Math, Religion, English <--- Inheritance of Person with id 1
Examiner | id | certificate
| 1 | Bachelor of Science <--- Inheritance of Person with id 1, too
有没有可能通过 Doctrine 注释来实现这一点?我不喜欢将实体 person 作为两个显式类的关系的想法。我更喜欢重现真实世界的情景,例如老师没有人,他是人。
希望任何人对我想要实现的目标有所了解。
谢谢!
【问题讨论】:
标签: php symfony doctrine-orm entity