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

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

问题描述

我一直在搜寻,这个问题被问了几次,但是似乎没有人能够给出确切的答案.如何使用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中设置整数长度.您只能选择 http://laravel.com/docs/schema#adding-columns 中描述的可用类型之一. a>.

Hence, you cannot set the integer length in Laravel either. You can only choose one of the available types described at http://laravel.com/docs/schema#adding-columns.

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

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