gpt4 book ai didi

mysql - 字符串外键更改的理论错误

转载 作者:行者123 更新时间:2023-11-29 17:51:43 24 4
gpt4 key购买 nike

这是我在 symfony 3.4 中更新架构时遇到的错误。当我将第二类中的referencedColumnName更改为第一类的id时,它没有给出错误。但是当我将其更改为第一类中的变量“costmodelinternal_name”时,它会给出以下错误。

In AbstractMySQLDriver.php line 121:

An exception occurred while executing 'ALTER TABLE cost_model_internal ADD CONSTRAINT FK_F59CC1232B401EC6 FOREIGN K
EY (costmodelinternal_name) REFERENCES bonus_calculation_1 (costmodelinternal_name)':

SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint


In PDOConnection.php line 106:

SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint


In PDOConnection.php line 104:

SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint


doctrine:schema:update [--complete] [--dump-sql] [-f|--force] [--em [EM]] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>

这里是类相关字段(一对多)关系

class BonusCalculation1
{
/**
* @ORM\OneToMany(targetEntity="CostModelInternal", mappedBy="bonus_calculation1")
*/
private $cost_model_internals;

public function __construct() {
$this->cost_model_internals = new ArrayCollection();
}
}

class CostModelInternal
{
/**
* @ORM\ManyToOne(targetEntity="BonusCalculation1", inversedBy="cost_model_internals")
* @ORM\JoinColumn(name="costmodelinternal_name", referencedColumnName="costmodelinternal_name")
*/
private $bonus_calculation1;
}

提前感谢您的帮助

最佳答案

实际上,我正在尝试不使用主键属性来构建关系。 Doctrine 中不允许的内容

关于mysql - 字符串外键更改的理论错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49270104/

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