簡體   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