【问题标题】:Doctrine Yaml Mapping Shared ColumnsDoctrine Yaml 映射共享列
【发布时间】:2014-01-16 00:27:25
【问题描述】:

是否可以使用 Yaml orm 文件来指定所有实体将共享的基本实体,我可以将其与 C# ADO.NET 进行比较,您可以在其中指定一个包含所有数据的类,这些数据将在所有实体中通用你的桌子

例如,假设我有以下 Doctrine 的 YAML 映射:

src\SITEBUNDLE\Entity\User:
    REALTYBLOG\Entity\User:
    type: entity
    table: users
    id:
        id:
            type:integer
            generator: { strategy: AUTO }
        fields:
            firstName:
                type: string
                length: 255
           lastName:
                type: string
                length: 255
            middleInital:
                type: string
                length: 1
            username:
                type:
                length: 26
            passwordHash:
                type: string
                length: 255
           createdOn:
                type: dateTime
           createdBy:
                type: string
                length: 26
           modifiedOn:
                type: dateTime
           modifiedBy:
                type: string
           deletedOn:
                type: dateTime

现在假设我创建了多个其他 YAML 配置,它们都共享 createdOn、createdBy、modifiedOn、modifiedBy、deletedOn 列。我可以指定一个覆盖的 orm 文件,我可以将其包含在我的所有 orm 文件中,这样我就不必将它们多余地添加到每个 orm 文件中吗?

【问题讨论】:

    标签: php symfony orm doctrine yaml


    【解决方案1】:

    是的,你可以。这很简单。

    TextItem:
      columns:
        topic: string(255)
    
    Comment:
      inheritance:
        extends: TextItem
        type: concrete
        columns:
         content: string(300)
    

    更多信息:http://docs.doctrine-project.org/projects/doctrine1/en/latest/en/manual/yaml-schema-files.html -> 继承/简单继承

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-09-20
      • 1970-01-01
      • 2012-09-06
      • 2011-10-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多