2015-04-18 20 views
1

嗨我正在開發一個symfony電影數據庫應用程序,面臨的問題很少。sql symfony實體關係orm電影數據庫

我有一個實體的內容(電影):

Bbd\MyAppBundle\Entity\Content: 
type: entity 
repositoryClass: Bbd\MyAppBundle\Repository\ContentRepository 
table: content 
id: 
    id: 
     type: integer 
     generator: { strategy: AUTO } 
fields: 
    title: 
     type: string 
     length: 120 
     unique: true 
.... 

然後,我有藝術家:

Bbd\MyAppBundle\Entity\Artist: 
type: entity 
table: artist 
id: 
    id: 
     type: integer 
     generator: { strategy: AUTO } 
fields: 
    name: 
     type: string 
     length: 255 
     unique: true 

然後,我有作用:現在

type: entity 
table: role 
id: 
    id: 
     type: integer 
     generator: { strategy: AUTO } 
fields: 
    name: ~ 

,一個內容將有許多角色,如:演員,女演員,導演..一位藝術家可能在一個內容中扮演很多角色。現在我不知道如何構建關係實體表。我想要一個表格,其中content_id,role_id,artist_id將被保存。

接下來的問題是我想從內容表單輸入所有數據,我希望從db中的所有角色都將顯示爲HTML標籤,並在其藝術家名稱框下拉列表旁邊。我真的不知道該怎麼做。有沒有什麼建議或者有更好的用戶友好的gui?

+0

您昨天有此問題? http://stackoverflow.com/questions/29692163/symfony2-many-to-many-relational-db-structure – ghanbari

回答

0

看來你是用YAML配置格式使用Doctrine2。

你想達到什麼是常見的情況,它是記錄在這裏很不錯: http://doctrine-orm.readthedocs.org/en/latest/reference/association-mapping.html

總是有對片段是「YAML」 -Tab。

+0

感謝您的建議。我也有同樣的問題。但你看到有三個表格有不同的關係。像內容角色oneToMany,角色藝術家manyToMany,所以我們必須需要一個連接表來處理所有的關係。我們如何能夠加入這三者並製造另一張桌子? –

+0

使用manyToMany原則模式更新程序將爲您創建連接表,一旦您獲得了配置權限。 –

+0

手指交叉我知道如何加入兩個表,但作爲即時通訊不擅長數據庫不知道如何加入三個表可以你我一個小例子..:p –