I know Doctrine 2.0 supports composite keys. But I am not quite able to find out what I am looking for.
I have 3 tables => agent, client and client_group.
Agent creates client and client_group. Client_Group has a composite primary key => id, agent_id. agent_id comes from the agent table. While I want the id to be auto incremented, the agent_id comes from agent table.
I am trying to write the yaml files but I am not sure how to specify this agent_id as a primary key in client_group. client_group_id and agent_id are foreign keys in client table. Also, I did read on the Doctrine documentation that composite PK cannot have fields that auto increment.
So I am wondring if I can really do what I am aiming to produce here.
The yaml showing only the relations look like this:
agent:
oneToMany:
client_group:
targetEntity: ClientGroup
mappedBy: agent
client:
targetEntity: Client
mappedBy: agent
client_group
manyToOne:
agent_id:
targetEntity: Agent
inversedBy: client_group
joinColumn:
name: agent_id
referencedColumnName: id
oneToMany:
client:
targetEntity: Client
mappedBy: client_group
client
manyToOne:
client:
targetEntity: ClientGroup
inversedBy: client
joinColumn:
name: client_group_id
referencedColumnName: id
agent:
targetEntity: Agent
inversedBy: agents
joinColumn:
name: agent_id
referencedColumnName: id
Any help on this would be aprreciated. Thanks.