How to get Doctrine TEXT type?(如何获得 Doctrine TEXT 类型?)
问题描述
我有这个注释:
/**
* @ORMColumn(name="notes", type="string", length=65532, nullable=true)
*/
protected $notes;
根据本文档 - http://doctrine-dbal.readthedocs.org/en/latest/reference/types.html#id102 因为它小于 65535 应该是 TEXT?
According to this document - http://doctrine-dbal.readthedocs.org/en/latest/reference/types.html#id102 because it's less than 65535 it should be TEXT?
但该列被创建为 MEDIUMTEXT.
But the column is created as MEDIUMTEXT.
我该如何解决这个问题?
How do I fix this?
推荐答案
您在文档中引用的类型不正确.在您的代码中,您有 type="string"
但您对文档的引用与 type="object"
有关.
You are referencing not correct type in the documentation. In your code you have type="string"
but your reference to documentation is related to type="object"
.
如果您阅读了参考文档中的上表部分,您将看到 string
在 MySQL 中被强制转换为 VARCHAR
如果 length
确实如此不超过 MySQL 的最大长度,如果 length
超过,则转换为 MEDIUMTEXT
.
If you read the part of table above in the referenced docs you will see that string
is casted to VARCHAR
in MySQL if length
does not exceed the maximum length for MySQL and is casted to MEDIUMTEXT
if length
exceeds.
但是,如果您想明确获得 TEXT
字段,则需要使用 type="text"
定义您的列.
But If you want to get explicitly TEXT
field you will need to define your column with type="text"
.
这篇关于如何获得 Doctrine TEXT 类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何获得 Doctrine TEXT 类型?


基础教程推荐
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- 带有WHERE子句的LAG()函数 2022-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
- 带更新的 sqlite CTE 2022-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01