Использование связей в Doctrine

задача: в таблице есть 2 поля user_id и ceated_at нужно к каждое из полей связать с 2 другими таблицами
в итоге получаем что-то вроде этого:

clUserMail:
  actAs:
    Timestampable: ~
    Signable: ~
  columns:
    user_to:      { type: integer, notnull: true }
    message_desc: { type: string(500) }
    message_body: { type: blob, notnull: true }
    message_type: { type: integer, default: 0 }
  relations:
    UserTo:
      class: sfGuardUser
      onDelete: CASCADE
      local: user_to
      foreign: id
      foreignAlias: clUserWallz
      alias: UserBy
      type: one
      foreignType: many
    UserInfoTo:
      class: clUserInformation
      onDelete: CASCADE
      local: user_to
      foreign: id
      foreignAlias: clUserWallz
      alias: UserInfoBy
      type: one
      foreignType: many
    UserFrom:
      class: sfGuardUser
      onDelete: CASCADE
      local: created_by
      foreign: id
      foreignAlias: clUserWalls
      alias: UserFrom
      type: one
      foreignType: many
    UserInfoFrom:
      class: clUserInformation
      onDelete: CASCADE
      local: created_by
      foreign: id
      foreignAlias: clUserWalls
      alias: UserInfoFrom
      type: one
      foreignType: many


Параметр class дает нам возможность использовать связи к одним и тем же таблицам для разных полей.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: