具有自定义主键名称的 symfony2 模型(不同于 "id")
symfony2 model with custom primary key name (different than "id")
任何人都可以粘贴一个 Symfony2
/Doctrine
模型的示例定义,该模型的主键不同于 id(名称,例如主键是 customer_id)?
我一直在网上搜索这个,我扫描了整个备忘单 (http://ormcheatsheet.com/) 但找不到。
例如,具有以下架构:
author:
type: entity
fields:
id:
id: true
type: integer
generator:
strategy: AUTO
我应该更改什么以将 id 替换为 author_id 并保留它仍然是主键?
是这样的吗?
author:
type: entity
id:
author_id:
type: integer
generator:
strategy: AUTO
fields:
name:
type: string
length: 50
任何人都可以粘贴一个 Symfony2
/Doctrine
模型的示例定义,该模型的主键不同于 id(名称,例如主键是 customer_id)?
我一直在网上搜索这个,我扫描了整个备忘单 (http://ormcheatsheet.com/) 但找不到。
例如,具有以下架构:
author:
type: entity
fields:
id:
id: true
type: integer
generator:
strategy: AUTO
我应该更改什么以将 id 替换为 author_id 并保留它仍然是主键?
是这样的吗?
author:
type: entity
id:
author_id:
type: integer
generator:
strategy: AUTO
fields:
name:
type: string
length: 50