我正在與Doctrine合作開展我的第一個Symfony項目,並且我碰到了一個麻煩。我試圖與兩名球員表達比賽。我想要的是PlayerOne和PlayerTwo,每個都被鍵入用戶表中的ID。這是我到目前爲止的一部分:與YAML的學說中的一對二關係
Game:
actAs: { Timestampable:- }
columns:
id: { type: integer, notnull: true, unique: true }
startDate: { type: timestamp, notnull: true }
playerOne: { type: integer, notnull: true }
playerTwo: { type: integer, notnull: true }
winner: { type: integer, notnull:true, default:0 }
relations:
User: { onUpdate: cascade, local: playerOne, foreign: id}
User: { onUpdate: cascade, local: playerTwo, foreign: id}
這是行不通的。它構建得很好,但它生成的SQL僅包含對playerTwo的約束。我試過其他的幾件事情:
User: { onUpdate: cascade, local: [playerOne, playerTwo], foreign: id}
另外:
User: [{ onUpdate: cascade, local: playerOne, foreign: id}, { onUpdate: cascade, local: playerTwo, foreign: id}]
最後兩個擲錯誤,當我嘗試建立。有沒有人瞭解我想要做什麼並可以幫助我實現目標?
+1。你不能有兩個具有相同名稱的關係,因爲你不能有兩個具有相同名稱的不同屬性。 – 2010-05-15 21:12:44