1
我想创建一个FAQ系统,其中系统管理员能在FAQ中的常见问题等,以创建另一个常见问题一SubFAQ ..学说自引用关联映射(Symfony的)
我知道我需要自我参考,但我怎么能解决这个问题?
我的实体FAQ.php看起来是这样的:
/**
* @OneToMany(targetEntity="Faq", mappedBy="parent")
*/
private $children;
/**
* @ManyToOne(targetEntity="Faq", inversedBy="children")
* @JoinColumn(name="parent_id", referencedColumnName="id")
*/
private $parent;
public function __construct() {
$this->children = new \Doctrine\Common\Collections\ArrayCollection();
}
什么我不明白的是inversedBy以及如何使用这一切。
谢谢。
http://stackoverflow.com/questions/12493865/what-is-the-difference-between-inversedby-and-mappedby#12495834可能会有帮助。 –
也http://doctrine-orm.readthedocs.io/projects/doctrine-orm/en/latest/reference/association-mapping.html#association-mapping。 –