【问题标题】:Symfony 2 and Database structure with ymlSymfony 2 和带有 yml 的数据库结构
【发布时间】:2011-12-01 10:45:03
【问题描述】:

在熟悉 Symfony 1.4 之后,我开始熟悉 Symfony-2。

我正在寻找一个从 yml 文件(或多个文件)创建数据库的好教程,但找不到。

是否可以在 yml 文件中定义表和约束之间的关系?我发现的唯一文档是关于实体文件中的元数据。

【问题讨论】:

    标签: symfony doctrine yaml


    【解决方案1】:

    请参阅Doctrine manual... 对于每个示例,您都可以在 PHP 注释XMLYAML 之间切换。

    【讨论】:

      【解决方案2】:

      请注意:某些约束将无法正常工作:例如如果您使用 MySQL PDO,则字符串类型列中的fixed 不会转换为CHAR,而是转换为VARCHAR。我还发现了一些未记录的 YALM 约束:

      唯一索引

      MyCompany\MyApp\MyClass:
        type: entity
        table: myclass
        uniqueConstraints:
          UNIQ_NAME:
          columns: [column1, column2]
      

      一般索引

      MyCompany\MyApp\MyClass:
        type: entity
        table: myclass
        indexes:
          IDX_NAME:
          columns: [column1, column2]
      

      【讨论】:

        猜你喜欢
        • 2013-02-04
        • 1970-01-01
        • 2012-06-26
        • 1970-01-01
        • 1970-01-01
        • 2014-06-17
        • 1970-01-01
        • 2013-11-01
        • 1970-01-01
        相关资源
        最近更新 更多