gpt4 book ai didi

symfony - 在Doctrine 2 ORM中命名关系吗?

转载 作者:行者123 更新时间:2023-12-04 10:43:09 24 4
gpt4 key购买 nike

如何使用YAML为多对一关系“区域”设置外键的名称(编辑:不是属性本身的名称)?

SWA\TestBundle\Entity\Province:
type: entity
table: province
uniqueConstraints:
UNIQUE_PROVINCE_CODE:
columns: code
id:
id:
type: integer
generator: { strategy: AUTO }
fields:
code:
type: integer
name:
type: string
length: 255
short_name:
type: string
length: 2
manyToOne:
region:
targetEntity: Region
inversedBy: provinces

最佳答案

查看getCreateConstraintSQL method in the AbstractPlatform class以查看如何选择外键的名称(line 1088)。

直接从约束名称中获取。影响约束名称将影响外键名称。

解决方法是删除约束,然后在a doctrine migration中使用新名称重新创建约束。

关于symfony - 在Doctrine 2 ORM中命名关系吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7623958/

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