Associations with Doctrine PHP

tdmpost

New Member
I'm trying to do an association of two objects with Doctrine (PHP).I have two objects : User and ConversationOne user has many conversations and a conversation belongs to two users maximum (on initiator of the conversation, and one receiver).So, in my Doctrine class I have this in the Conversation class :\[code\]$this->hasOne('User as Initiator', array('local' => 'initiator_id', 'foreign' => 'id'));$this->hasOne('User as Responder', array('local' => 'responder_id', 'foreign' => 'id'));\[/code\]And in the User class :\[code\]$this->hasMany('Conversation as Conversations', array('local'=> 'id', 'foreign'=> ????));\[/code\]For this foreign key I'd like to put something that means "initiator_id OR responder_id".I guess I need a junction table to accomplish what I want to do ? What would you do in this case ?Thank you for your answers,Martin
 
Back
Top