gpt4 book ai didi

php - 了解双向关系中拥有方如何运作

转载 作者:行者123 更新时间:2023-12-03 09:24:31 25 4
gpt4 key购买 nike

我正在使用 php app/consoledoctrine:schema:validate 任务验证项目模式(代码不是我的,我只是想让它正常工作)。我看到的常见消息之一是:

  • The field Mapyet\AfiliadoBundle\Entity\Widget#negocio is on the owning side of a bi-directional relationship, but the specified mappedBy association on the target-entity Mapyet\AfiliadoBundle\Entity\Negocio# does not contain the required 'inversedBy' attribute.

这就是 $negocioWidget.php 实体中的定义方式:

/**
* @ORM\ManyToOne(targetEntity="Negocio", mappedBy="widget")
*/
private $negocio;

这就是 $widgetNegocio.php 实体中的定义方式:

/**
* @ORM\OneToMany(targetEntity="Widget", inversedBy="negocio")
*/
private $widget;

这个定义有什么问题?

最佳答案

反转它们:

Widget.php

/**
* @ORM\ManyToOne(targetEntity="Negocio", inversedBy="widget")
*/
private $negocio;

Negocio.php

/**
* @ORM\OneToMany(targetEntity="Widget", mappedBy="negocio")
*/
private $widget;

http://docs.doctrine-project.org/en/2.0.x/reference/association-mapping.html#one-to-many-bidirectional

关于php - 了解双向关系中拥有方如何运作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23791750/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com