One to two relationship in Doctrine with YAML
Posted
by Jeremy DeGroot
on Stack Overflow
See other posts from Stack Overflow
or by Jeremy DeGroot
Published on 2010-05-11T00:24:48Z
Indexed on
2010/05/11
0:34 UTC
Read the original article
Hit count: 288
I'm working on my first Symfony project with Doctrine, and I've run into a hitch. I'm trying to express a game with two players. The relationship I want to have is PlayerOne and PlayerTwo each being keyed to an ID in the Users table. This is part of what I've got so far:
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}
That doesn't work. It builds fine, but the SQL it generates only includes a constraint for playerTwo. I've tried a few other things:
User: { onUpdate: cascade, local: [playerOne, playerTwo], foreign: id}
Also:
User: [{ onUpdate: cascade, local: playerOne, foreign: id}, { onUpdate: cascade, local: playerTwo, foreign: id}]
Those last two throw errors when I try to build. Is there anyone out there who understands what I'm trying to do and can help me achieve it?
© Stack Overflow or respective owner