Search code examples
symfony1doctrinesymfony-1.4sfguard

symfony two id fields from same id table


I'm using symfony for a project but got stuck at one point building the schema. In the schema I have one table user that can be created by himself or and administrator and the user ids are stored in sfGuardUser... how can y make a relation between them in the schema.yml?

I have this fields:

tableX

sf_guard_user_id: {type: integer}
sf_guard_user_id_cs: {type: integer}

The first id is the one he gets when created and the second is the administrator's id if it was created by one. So basically, I'm gonna use the id field from sfGuardUser twice in tableX but I'm not able to make this two relations in the schema.yml. Anyone knows how to do the relations?


Solution

  • It is simple. For example:

    CoolTable:
      actAs:
         Timestampable: ~
      columns:
        sf_guard_user_id:    { type: integer() }
        sf_guard_user_id_cs: { type: integer() }
      relations:
        User:    { local: sf_guard_user_id, foreign: id, class: sfGuardUser }
        UserCs:  { local: sf_guard_user_id_cs, foreign: id, class: sfGuardUser }
    

    Main point, that you specify the class of relations.