gpt4 book ai didi

mysql - Symfony 3.4 Doctrine : The association refers to the inverse side field which is not defined as association

转载 作者:行者123 更新时间:2023-11-29 17:56:47 27 4
gpt4 key购买 nike

实体\识别

/**
* @ORM\Entity
* @ORM\Table(name="c_rcgntn")
*/
class Recognition {
/**
* @ORM\Id
* @ORM\Column(type="integer", name="id")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;

/**
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\RecognitionType", inversedBy="id")
* @ORM\JoinColumn(name="fk_recogtype_id", referencedColumnName="id")
*/
protected $recogType;

实体\识别类型

/**
* @ORM\Entity
* @ORM\Table(name="c_rcgntn_type")
*/
class RecognitionType {
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\OneToMany(targetEntity="AppBundle\Entity\Recognition",mappedBy="recogType")
*/
protected $id;

在我的开发环境中运行此程序时,我看到错误显示在我的分析器中。这不是一个大问题,因为代码仍然运行并正确返回连接。我就是无法摆脱这个错误。

The association Entity\Recognition#recogType refers to the inverse side field Entity\RecognitionType#id which is not defined as association. The association Entity\Recognition#recogType refers to the inverse side field Entity\RecognitionType#id which does not exist.

最佳答案

您将 RecognitionType 中“id”字段的定义与识别实体的关系混合在一起。从 RecognitionType 中删除行:

@ORM\OneToMany(targetEntity="AppBundle\Entity\Recognition",mappedBy="recogType")

这对于单向关系来说应该足够了,您对 recogType 字段的定义就足够了。

如果您还想在 RecognitionType 中添加关系,则向其中添加一个新字段:

/**
* ORM\OneToMany(targetEntity="AppBundle\Entity\Recognition", mappedBy="recogType")
*/
protected $recognition;

请注意,上述定义后不需要更新架构。

关于mysql - Symfony 3.4 Doctrine : The association refers to the inverse side field which is not defined as association,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48738545/

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