整数的模式生成器长度 [英] Schema Builder length of an integer

查看:24
本文介绍了整数的模式生成器长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在四处寻找,这个问题被问了几次,但似乎没有人能够给出明确的答案.如何使用 Schema 指定表列的整数长度?

I've been searching around and the question was asked a few times, but no-one seem to be able to give a definite answer to it. How do you specify the integer length for the table column using Schema?

我看到有人建议:

$table->integer('post')->length(11);

但这不起作用 - 至少在 Laravel 4.2 中 - 它仍然将列生成为 int(10).

But that doesn't work - at least with Laravel 4.2 - it still produces the column as int(10).

是否有指定整数长度的内置方法?

Is there a built in method to specify the integer length?

推荐答案

如果您使用的是 MySQL,则无法指定整数列的长度.您只能在 中描述的一种可用整数类型之间进行选择http://dev.mysql.com/doc/refman/5.1/en/integer-types.html.

If you're using MySQL, you can't specify the length of an integer column. You can only choose between one of the available integer types, described at http://dev.mysql.com/doc/refman/5.1/en/integer-types.html.

因此,您也不能在 Laravel 中设置整数长度.

Hence, you cannot set the integer length in Laravel either.

您只能选择其中描述的可用类型之一Laravel 4.2 数据库迁移创建列.

You can only choose one of the available types described at Laravel 4.2 Database Migration Creating Column.

这篇关于整数的模式生成器长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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