在同一实体类型中添加实体的 ArrayCollection
Add ArrayCollection of Entities in the same entity type
是否可以在实体 A 中保留实体 A 的数组?如何使用 Doctrine 做到这一点?
我有:
class A {
/**
* @var \Doctrine\Common\Collections\ArrayCollection
*/
private $sisters;
}
但我不知道要添加什么才能让 Doctrine 做我需要的事情。
A
可以有很多姐妹,很多姐妹可以是A
的姐妹(多对多,自引用):
/**
* @ORM\Entity()
* @ORM\Table()
*/
class A
{
/**
* @var integer
*
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
protected $id;
/**
* @var \Doctrine\Common\Collections\ArrayCollection
* @ORM\ManyToMany(targetEntity="AppBundle\Entity\A")
*/
private $sisters;
}
是否可以在实体 A 中保留实体 A 的数组?如何使用 Doctrine 做到这一点?
我有:
class A {
/**
* @var \Doctrine\Common\Collections\ArrayCollection
*/
private $sisters;
}
但我不知道要添加什么才能让 Doctrine 做我需要的事情。
A
可以有很多姐妹,很多姐妹可以是A
的姐妹(多对多,自引用):
/**
* @ORM\Entity()
* @ORM\Table()
*/
class A
{
/**
* @var integer
*
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
protected $id;
/**
* @var \Doctrine\Common\Collections\ArrayCollection
* @ORM\ManyToMany(targetEntity="AppBundle\Entity\A")
*/
private $sisters;
}