Doctrine orm 条令2.2.2带注释的数据库表关系
我对条令2是如此陌生,在数据库表关系方面不是那么好。我了解多对一、一对多、一对一和多对多关系的运作方式。我只是对下面使用CLI生成数据库表时出现的错误感到困惑Doctrine orm 条令2.2.2带注释的数据库表关系,doctrine-orm,Doctrine Orm,我对条令2是如此陌生,在数据库表关系方面不是那么好。我了解多对一、一对多、一对一和多对多关系的运作方式。我只是对下面使用CLI生成数据库表时出现的错误感到困惑 [Doctrine\ORM\ORMException] Column name `id` referenced for relation from Kent\Entity\DoctorSpecialties towards Kent\Entity\Doctors does not exist. 请查看此github链接以查看我的
[Doctrine\ORM\ORMException]
Column name `id` referenced for relation from Kent\Entity\DoctorSpecialties towards Kent\Entity\Doctors does not exist.
请查看此github链接以查看我的实体。(Doctors.php和DoctorSpecialties.php)
注意:我使用的是Zend Framework 1.11.12,这是您必须在DoctorSpecialties类中添加的注释
@ManyToOne(targetEntity="Doctors")
@JoinColumn(name="doctor_id", referencedColumnName="doctor_id")
这些是您必须在DoctorSpecialties类上添加的注释
@ManyToOne(targetEntity="Doctors")
@JoinColumn(name="doctor_id", referencedColumnName="doctor_id")
在多对多关系中,必须对第三个forignkey表进行引用 所以改变这个
/**
*
* @var Doctors
* @ManyToMany(targetEntity="Doctors", mappedBy="specialties")
* @JoinTable(name="doctor_specialties")
*/
protected $doctors
希望这有助于在多对多关系中,您必须参考第三个forignkey表 所以改变这个
/**
*
* @var Doctors
* @ManyToMany(targetEntity="Doctors", mappedBy="specialties")
* @JoinTable(name="doctor_specialties")
*/
protected $doctors
希望这有帮助我想你最好看看这里:
我认为你最好看看这里: