Jot*_*sha 2 bundle symfony doctrine-orm symfony2-easyadmin
无论如何在symfony2中的EasyAdmin包中做一对多的关系?
到目前为止,我让我的用户工作,但不是其他具有一对多关系的实体.
我在MySQL的学说中有数据库.
fcp*_*iaz 10
EasyAdminBundle支持各种实体关联.
没有关于实体关联的文档,因为它不是EasyAdminBundle的一部分,而是Doctrine.例如,这是OneToMany Association.
/**
*
* @var ArrayCollection
* @ORM\OneToMany(targetEntity="DocumentBundle\Entity\Document", mappedBy="course")
*
*/
private $documents;
public function __construct()
{
$this->documents = new \Doctrine\Common\Collections\ArrayCollection();
}
Run Code Online (Sandbox Code Playgroud)
这是协会的另一面
/**
* Many-to-one relationship between documents and course
*
* @var ArrayCollection
* @ORM\ManyToOne(targetEntity="CourseBundle\Entity\Course",inversedBy="documents")
* @ORM\JoinColumn(name="course_id", referencedColumnName="id")
*/
private $course;
Run Code Online (Sandbox Code Playgroud)
配置就像这样:
easy_admin:
site_name: 'Learn-In Admin'
entities:
Courses:
class: CourseBundle\Entity\Course
new:
fields: ['name','code']
Documents:
class: DocumentBundle\Entity\Document
Run Code Online (Sandbox Code Playgroud)
您可以在Doctrine文档中找到有关关联映射的所有示例.
| 归档时间: |
|
| 查看次数: |
5722 次 |
| 最近记录: |