繁体   English   中英

找不到字段的映射

[英]No mapping found for field

我必须去实体

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对不起,我的英语

你必须参考patient的,而不是在ContactAddress实体病人* S *。

class Patients 
{
     /**
     * @ORM\OneToOne(targetEntity="ContactAddress", mappedBy="patient")
     */
    protected $contactaddress;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM