关于 artisan migrate 的问题,如何给 tinyInteger 类型加长度限制?

public function tinyInteger($column, $autoIncrement = false, $unsigned = false)
{
    return $this->addColumn('tinyInteger', $column, compact('autoIncrement', 'unsigned'));
}

怎么设置tinyInteger的长度捏?

    Schema::create('backend_user', function (Blueprint $table) {
        $table->increments('id');
        $table->string('nickname');
        $table->string('email')->unique();
        $table-> tinyInteger('type)->unique();
        $table->string('password', 32);
        $table->timestamps();
    });
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 1

哥们,tinyInteger分为有符号和无符号,无符号是0-255,有符号是-127-127.你还限制他的长度干啥?明白了吗?最怕设计数据库的人不明白字段的属性,就瞎搞。另外,设置长度只是设置的显示的位数,例如,你设置int(2),表示只显示前两个数字,但是范围还是正负21亿。占的空间是4byte.

6年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!