Doctrine ORM自定义列整理

ikl*_*man 10 orm symfony doctrine-orm

我正在尝试设置自定义列排序规则,如Doctrine文档中所示:

运用

@ORM\Column(name="body", type="string", length=140, options={"customSchemaOptions"={"collate"="utf8mb4_unicode_ci"}})

但是当我更新架构时,它总是返回到utf8_unicode_ci(当我手动设置它时).有任何想法吗?

Nie*_*jes 24

如果您(或其他人)仍然需要,现在已添加此内容,请参阅列注释文档

示例:在注释中:

/**
 * @var string
 *
 * @ORM\Column(type="string", length=64, nullable=false, options={"collation":"utf8_bin"})
 */
private $code;
Run Code Online (Sandbox Code Playgroud)

在Yaml:

Your\Nice\Entity:
    fields:
        code:
            type: string
            length: 64
            options:
                collation: utf8_bin   # Although the recommendation is the utf8mb4* set now.
Run Code Online (Sandbox Code Playgroud)

现在所有常见的数据库驱动程序都支持此功能

  • 它确实受支持,但不是可移植的。如果您将排序规则设置为“ utf8_bin”,它将在sqlite上失败。 (2认同)