在Doctrine中与YAML的一对二关系

Jer*_*oot 3 mysql yaml doctrine symfony1

我正在与Doctrine一起开展我的第一个Symfony项目,而且我遇到了麻烦.我正试图用两名球员表达一场比赛.我想要的关系是PlayerOne和PlayerTwo,每个都被键入Users表中的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}
Run Code Online (Sandbox Code Playgroud)

这不起作用.它构建良好,但它生成的SQL只包含playerTwo的约束.我尝试过其他一些东西:

User: { onUpdate: cascade, local: [playerOne, playerTwo], foreign: id}
Run Code Online (Sandbox Code Playgroud)

也:

    User: [{ onUpdate: cascade, local: playerOne, foreign: id}, { onUpdate: cascade, local: playerTwo, foreign: id}]
Run Code Online (Sandbox Code Playgroud)

我尝试构建时最后两次抛出错误.那里有谁知道我正在做什么,可以帮助我实现它吗?

Ale*_*nov 6

尝试不同的关系名称:

  relations:
    UserOne: { onUpdate: cascade, local: playerOne, foreign: id, class: User }
    UserTwo: { onUpdate: cascade, local: playerTwo, foreign: id, class: User }
Run Code Online (Sandbox Code Playgroud)

编辑:还注意添加了"class:User"参数,该参数明确说明了关系的类型.