我创建了两个条令实体,如下所示。
class Corporate {
/**
* @ORM'Id
* @ORM'GeneratedValue(strategy="AUTO")
* @ORM'Column(type="integer")
*/
protected $id;
....
...
/**
* @ORM'OneToMany(targetEntity="CorporateJobs", mappedBy="corporate", cascade={"persist","remove"})
**/
private $corporate_jobs;
}
以及在CorporateJobs实体表中类似对应的ManytoOne关系。
class CorporateJobs {
/**
* @ORM'Id
* @ORM'GeneratedValue(strategy="AUTO")
* @ORM'Column(type="integer")
*/
protected $id;
/**
* @ORM'ManyToOne(targetEntity="Corporate")
* @ORM'JoinColumn(name="corporate_id", referencedColumnName="id", nullable=true)
**/
private $corporate;
}
在从Indexcontroller检索值时,它没有进入我的corporateJobs表。
array(22){["id"]=>int(6)["prefix"]=>NULL["first_name"]=>string(8)"暴徒"["last_name"]=>string(1)"b"["corporate_jobs"]=>数组(0){}}
corporate_jobs表具有类似corporate_id jobtitle jobdescription location的字段/Corporate_id映射到企业实体中的user_id或Corporate_id。
@ORM'ManyToOne(targetEntity="Corporate")
@ORM'OneToMany(targetEntity="CorporateJobs")
targetEntity需要实体的完整命名空间,否则Doctrine将不知道公司实体的任何表映射。