【发布时间】:2011-02-17 22:29:41
【问题描述】:
我正在使用 Doctrine 进行我的第一个 Symfony 项目,但遇到了麻烦。我试图表达一个有两个玩家的游戏。我想要的关系是 PlayerOne 和 PlayerTwo 分别被键入用户表中的一个 ID。这是我到目前为止所得到的一部分:
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}]
当我尝试构建时,最后两个抛出错误。有没有人了解我正在尝试做的事情并可以帮助我实现它?
【问题讨论】:
标签: mysql symfony1 doctrine yaml