【问题标题】:Symfony (Doctrine) : Fixtures one to many relation with custom fieldsSymfony (Doctrine):固定与自定义字段的一对多关系
【发布时间】:2012-03-16 13:05:44
【问题描述】:

我正在寻找为以下架构(电影库)创建固定装置文件:

VodProgram:
  actAs: { Timestampable: ~ }
  columns:
    title:              { type: string(255), notnull: true }
    year:               { type: smallint }
    ...
  relations:
    VodPersons:
      class: VodPerson
        refClass: VodCasting
        local: program_id
        foreign: person_id
        foreignAlias: VodPrograms

VodPerson:
  columns:
    name:               { type: string(255), notnull: true }

VodCasting:
  columns:
    program_id:         { type: integer, primary: true }
    person_id:          { type: integer, primary: true }
    role:               { type: string(255) }
    rank:               { type: smallint }
  relations:
    VodProgram:         { onDelete: CASCADE, local: program_id, foreign: id }
    VodPerson:          { onDelete: CASCADE, local: person_id, foreign: id }

我的问题是使用 VodCasting 表中存在的“角色”和“等级”字段创建固定文件。

这是我的实际装置:

VodPerson:
  kosinski:
    name: Joseph Kosinski

VodProgram:
  tron:
    VodPersons: [kosinski] # where to put the role and rank infos ?
    title: Tron
    year: 2010

我试过类似的东西:

VodProgram:
  tron:
    VodPersons:
      kosinski:
        rank: 1
    title: Tron
...

没有运气。

有什么建议吗?

谢谢。

【问题讨论】:

    标签: symfony1 doctrine fixtures


    【解决方案1】:

    你有没有尝试过这样的事情:

    VodPerson:
      kosinski:
        name: Joseph Kosinski
    
    VodProgram:
      tron:
        title: Tron
        year: 2010
    
    VodCasting:
      tron_kosinski:
        role: 'Director'
        rank: 1
        VodPerson: kosinski
        VodProgram: tron
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-08-27
      • 2022-01-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-09
      相关资源
      最近更新 更多