Symfony 中的多对多和多对一关系

Many to many and Many to One relation in Symfony

我有一个场景 在哪里 许多人属于许多企业,并且 许多人属于许多子企业

另外1个商家可能有多个子商家

我完成了 1 个业务属于多个子业务的部分

对于我们有 2 个多对多业务的 Persons 实体,我正在寻找具有以下结构的连接 table

加入Table姓名:person_business

加入 Table 字段:person_id,business_id,subbusiness_id

我做的是

 /**
     * Business
     *
     * @ORM\ManyToMany(targetEntity = "buslvlone", inversedBy = "id")
     * @ORM\JoinTable(name = "person_business")
     */
    private $businesses;

    /**
     * Sub Business
     *
     * @ORM\ManyToMany(targetEntity = "buslvltwo", inversedBy = "id")
     * @ORM\JoinTable(name = "person_business")
     */
    private $subbusiness;

但是当我 运行 从控制台更新模式时我得到错误 "The table with name 'advocacy_business' already exists."

您有两个实体使用相同的注释:

/** @ORM\Table(name="advocacy_business") */