2015-10-02 30 views
1

任何人可以粘貼具有主鍵比ID(名稱,不同的一個Symfony2/Doctrine模型的示例定義例如主鍵是customer_id)?Symfony2的模型使用自定義主鍵名稱(除「ID」不同)

我一直在網上搜索這個,我掃描了整個cheatsheet(http://ormcheatsheet.com/),但找不到一個。

例如,將具有以下模式:

author: 
    type: entity 
    fields: 
    id: 
     id: true 
     type: integer 
     generator: 
     strategy: AUTO 

我應該改變更換IDAUTHOR_ID保留它仍然是主要的關鍵是什麼?

回答

4

像這樣的東西?

author: 
    type: entity 
    id: 
    author_id: 
     type: integer 
     generator: 
     strategy: AUTO 
    fields: 
    name: 
     type: string 
     length: 50 

reference

相關問題