命令关系在教义2 ORM? [英] Naming a relation in Doctrine 2 ORM?
本文介绍了命令关系在教义2 ORM?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用YAML设置多对一关系区域的外键名称(编辑:不是属性本身的名称)
How can i set the name of the foreign key (edit: not the name of the attribute itself) for the many-to-one relation "region" using 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方法AbstractPlatform类,以查看如何选择外键的名称(第1088行)。
Look at the getCreateConstraintSQL method in the AbstractPlatform class to see how the name of the foreign key is chosen (line 1088).
直接来自约束名称。影响约束名称将影响外键名称。
It is taken directly from the constraint name. Influencing constraint name will influence the foreign key name.
作为解决方法,您可以删除约束并在一个原则迁移。
As a workaround you could drop the constraint and re-create it with a new name in a doctrine migration.
这篇关于命令关系在教义2 ORM?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文