我要实体
class Patients
{
/**
* @ORM\OneToOne(targetEntity="ContactAddress", mappedBy="patients")
*/
protected $contactaddress;
}
还有一个
class ContactAddress
{
/**
* @ORM\OneToOne(targetEntity="Patients", inversedBy="contactaddress")
* @ORM\JoinColumn(name="patient_id", referencedColumnName="id")
*/
protected $patient;
}
当我尝试执行这段代码时
$em = $this->getDoctrine()->getEntityManager();
$product = $em->getRepository('SurgeryPatientBundle:Patients')->find($id);
我明白了
No mapping found for field 'patients' on class 'Surgery\PatientBundle\Entity\ContactAddress'.
当我尝试访问联系人存储库时,我得到了结果
请帮忙;D 对不起我的英语
最佳答案
您必须在 ContactAddress 实体中引用 patient
而不是 patient*s*。
class Patients
{
/**
* @ORM\OneToOne(targetEntity="ContactAddress", mappedBy="patient")
*/
protected $contactaddress;
}
https://stackoverflow.com/questions/14222550/