【问题标题】:How to add comment for table in yaml mapping format with Doctrine2如何使用 Doctrine2 为 yaml 映射格式的表添加注释
【发布时间】:2014-11-11 13:59:24
【问题描述】:

我需要为整个表格添加注释,而不仅仅是列,我该如何使用yml 映射格式来做到这一点。我尝试下一个定义:

Acme\DemoBundle\Entity\User:
    type: entity
    table: users
    comment: 'Users table'
    options:
        comment: 'Users table'

但它不适用于表格注释。

【问题讨论】:

  • 检查this答案。
  • @StivenLlupa 谢谢,看起来不错,但使用了annotation。我需要同样的,但yaml 格式。
  • 它们基本相同,只是遵循相同的“模式”和“深度”。试一试
  • @StivenLlupa 我更新了我的问题。还是不行

标签: symfony doctrine-orm comments yaml


【解决方案1】:

您必须在表格标签的options 部分中包含coments 部分。举个例子:

Acme\DemoBundle\Entity\User:
    type: entity
    table: users
    options:
        comment: 'Table comment'
    fields:
        field1:
            type: field_type
            nullable: [true|false]
            options:
                comment: 'Field comment'
            column: table_column

注意缩进。

使用 Symfony 2.6.6、Doctrine 2.5.4 测试

【讨论】:

  • 嘿,谢谢!它适用于 MySQL 吗?您测试了哪个数据库服务器?
  • 肯定的,MySQL 5.5
【解决方案2】:

根据注释参考,它说只有列具有 cmets 的选项属性。这也是特定于供应商的。您需要检查您的数据库是否支持它。

检查:http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/annotations-reference.html#annref-column

【讨论】:

  • 我使用的 MySQL 数据库支持 cmets for tables
  • 看起来您只能为列而不是表使用 cmets。
  • 查看ALTER TABLE 语法。我可以评论表格
  • 是的,但我的意思是教义没有办法添加它。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-10-20
  • 1970-01-01
  • 2021-11-11
  • 1970-01-01
  • 2013-06-17
  • 2012-11-11
相关资源
最近更新 更多