如何获取教义文本类型? [英] How to get Doctrine TEXT type?

查看:47
本文介绍了如何获取教义文本类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个注释:

/**
 * @ORM\Column(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.

我该如何解决?

推荐答案

您在文档中引用的类型不正确.在您的代码中,您有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".

如果您在参考文档中阅读了上表的一部分,您会发现,如果length不超过MySQL的最大长度,则在MySQL中将string强制转换为VARCHAR,如果在MEDIUMTEXT中,强制转换为MEDIUMTEXT length超出了.

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".

这篇关于如何获取教义文本类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆