Doctrine ORM 自定义列整理 [英] Doctrine ORM Custom Column Collation
本文介绍了Doctrine ORM 自定义列整理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试按照 Doctrine 文档设置自定义列排序规则:
I'm trying to set custom column collation as in Doctrine documentation:
- http://doctrine-dbal.readthedocs.org/en/latest/reference/schema-representation.html 和
- http://doctrine-orm.readthedocs.org/en/latest/reference/annotations-reference.html
使用
@ORMColumn(name="body", type="string", length=140, options={"customSchemaOptions"={"collate"="utf8mb4_unicode_ci"}})
但是当我更新架构时,它总是回到 utf8_unicode_ci (例如,当我手动设置它时).有什么想法吗?
but when I update the schema it always goes back to utf8_unicode_ci (when I set it manually for example). Any ideas?
推荐答案
如果您(或其他人)仍然需要,现在已经添加了,请参阅 列注释文档
This has been added by now if you (or someone else) still need, see column annotation docs
示例:在注释中:
/**
* @var string
*
* @ORMColumn(type="string", length=64, nullable=false, options={"collation":"utf8_bin"})
*/
private $code;
在 Yaml 中:
YourNiceEntity:
fields:
code:
type: string
length: 64
options:
collation: utf8_bin # Although the recommendation is the utf8mb4* set now.
现在所有常见的数据库驱动程序都支持这一点.
This is supported by all common database drivers now.
这篇关于Doctrine ORM 自定义列整理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文