学说关系.无法弄清楚



im试图建立2个具有关系的实体,但关系与每个角度略有不同,所以..

我试图做到这一点,所以一个节目可以有多个引号..但是从报价中,只有1个节目链接。

所以它就像一个oneTomany的表演和报价中的OneToone。这是可能的吗?

然后,在我的节目中,我可以获得$ show-> getQuotes()来检索所有引号P>

希望有人可以帮助我围绕它

这听起来像是默认的onetomany关系。您的实体应该看起来像下面。引号是一个带有多个条目的表演中的集合,而引用的getShow()有一个返回show-object的getter。

class Show{
   public function __construct()
    {
        $this->quotes = new ArrayCollection();
    }
/**
* @ORMId
*/
private $id;

/**
* One Show has Many Quotes.
*
* @OneToMany(targetEntity="Quotes", mappedBy="show")
*/
private $quotes;
}

class Quotes{
/**
* @ORMId
*/
private $id;

 /**
 * Many Quotes have One Show
 * @ManyToOne(targetEntity="AppEntityShow",inversedBy="quotes")
 * @JoinColumn(name="ID_SHOW", referencedColumnName="ID")
 */
private $show;
}

相关内容

最新更新