Php 如何使自增列成为非自增列?

Php 如何使自增列成为非自增列?,php,mysql,laravel-5,Php,Mysql,Laravel 5,我正试图用这段代码创建一个表 public function up() { Schema::create('BookInfo', function (Blueprint $table) { $table->increments('id'); $table->integer('bookId',11); $table->string('Name',255); $table->string('Publish

我正试图用这段代码创建一个表

public function up()
{
    Schema::create('BookInfo', function (Blueprint $table) {
        $table->increments('id');
        $table->integer('bookId',11);
        $table->string('Name',255);
        $table->string('Publisher')->nullable();
        $table->integer('Publishing_year',4)->nullable();
        $table->integer('Price',5)->nullable();
        $table->string('Language',30);
        $table->timestamps();
    });
}
当我尝试
php artisan migrate
时,它显示了这个错误

[Lightning\Database\QueryException]
SQLSTATE[42000]:语法错误或访问冲突:1075不正确 表格定义;只能有一个自动列,并且必须 被定义为键(SQL:create table
BookInfo
bookId
int非
自动递增主键为空,
Name
varchar(255)不为空,
Publisher
varchar(255)null,
Publishing\u year
int null
自动增量主键,
Price
int null自动增量主键,
Language
varchar(30)非空,
时间戳默认值0处创建
非空,
时间戳默认值0非空)处更新\u默认字符
设置utf8 collate utf8\u unicode\u ci)

[PDO异常]
SQLSTATE[42000]:语法错误或访问冲突:1075不正确 表格定义;只能有一个自动列,并且必须为 定义为键

似乎laravel将所有整数列都视为自动增量。这里到底发生了什么,解决方案是什么?

错误说明了一切

$table->integer('bookId',11);
                          ^// this is considered as autoincrement rather than length
整数没有长度选项

参考文献如此,错误说明了一切

$table->integer('bookId',11);
                          ^// this is considered as autoincrement rather than length
整数没有长度选项

参考SO和

$table->integer('bookId',11)在雄辩的ORM中语法不正确(您不能为整数设置任何大小限制),这会导致您的案例中出现错误

$table->increments('id')自动将
id
设置为
主键

在这里找到雄辩的ORM中所有必要的表格生成命令:

$table->integer('bookId',11)在雄辩的ORM中语法不正确(您不能为整数设置任何大小限制),这会导致您的案例中出现错误

$table->increments('id')自动将
id
设置为
主键

在雄辩的ORM中找到所有必要的表格构建命令: