长度为255的Doctrine2列类型整数不适用于DB [英] Doctrine2 column type integer of length 255 doesn't apply to DB

查看:186
本文介绍了长度为255的Doctrine2列类型整数不适用于DB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的数据库使用Doctrine 2,而我正在尝试为我的一个列设置一个整数类型的长度,但它似乎似乎没有。

I'm using Doctrine 2 for my DB and I'm currently trying to set a length for one of my column that has an "integer" type but it just doesn't seem to be taken.

/** @Column(type="integer", length=255) */
protected $number;

当我检查我的数据库时,它仍然显示int(11)而不是int(255) 。我没有发现任何人在谷歌遇到这个问题,或者我的关键字不是很好。我看过一些人使用长度= XXX并没有抱怨它的例子所以我认为这将是要走的路,但到目前为止还不好...

When I check my database it still says "int(11)" instead of "int(255)". I haven't found anyone experiencing that problem on google or maybe my keywords ain't working so good. I've seen a few example of people using length=XXX and not complaining about it so I thought it would be the way to go but so far no good...

我总是丢弃/重建整个数据库和代理等等,所以我怀疑它来自那里。

I'm always dropping/rebuilding the whole DB and proxies etc so I doubt it comes from there.

推荐答案

这是因为你不能在MySQL里有这么大的 INT

It is because you cannot have such a big INT in MySQL.

尝试使用类型 BIGINT 相反,它从-9223372036854775808变为9223372036854775807(签名)或从0到18446744073709551615(未签名)。

Try using the type BIGINT instead, it goes from -9223372036854775808 to 9223372036854775807 (signed) or from 0 to 18446744073709551615 (unsigned).

Doctrine version:

Doctrine version:

/** @Column(type="bigint") */
protected $number; 

手册

这篇关于长度为255的Doctrine2列类型整数不适用于DB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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