0

我有这个结构

`UserInterface.php`
 abstract class User implements UserInterfacee in model`
`class student extends user.php`
`class teacher extends user.php`

现在我应该在哪个班级使用这个学说代码

/**
 * @Entity
 * @InheritanceType("JOINED")
 * @DiscriminatorColumn(name="discr", type="string")
 * @DiscriminatorMap({"user" = "User", "student" = "Student"})
 */
4

1 回答 1

2

您应该在父类中使用继承注释。

/**
 * @Entity
 * @InheritanceType("JOINED")
 * @DiscriminatorColumn(name="discr", type="string")
 * @DiscriminatorMap({"student" = "Student", "teacher" = "Teacher"})
 */
  class User
 {
 // ...
 }

  /** @Entity */
  class Student extends User
   {
    // ...
  }

  /** @Entity */
  class Teacher extends User
   {
    // ...
  }
于 2012-07-13T02:37:18.650 回答