【发布时间】:2016-05-13 10:51:49
【问题描述】:
我遇到了一个通信错误,我无法解决它,知道 [Illuminate\Database\QueryException] SQLSTATE[42000] 这是完整的错误:
[Illuminate\Database\QueryException] SQLSTATE[42000]:语法错误 或访问冲突:1064 您的 SQL 语法有错误;查看 与您的 MySQL 服务器版本相对应的手册 在第 1 行的“无符号空”附近使用正确的语法(SQL:alter 表
files添加slugvarchar(255) 无符号空)
一个单独的错误:
[PDOException] SQLSTATE[42000]:语法错误或访问冲突: 1064 您的 SQL 语法有错误;检查手册 对应于您的 MySQL 服务器版本,以便使用正确的语法 第 1 行的“无符号空值”附近
他是我试图做外键的表:
文件
public function up()
{
Schema::create('files', function($table)
{
$table->engine = 'InnoDB';
$table->increments('id')->unsigned();
$table->string('name')->nullable();
$table->boolean('enable_sch')->nullable();
$table->datetime('schdate')->nullable();
$table->string('flsize')->nullable();
$table->timestamps();
});
Schema::table('files', function($table)
{
$table->string('slug')->unsigned()->nullable();
$table->foreign('slug')->references('slug')->on('slugs');
});
}
蛞蝓
public function up()
{
Schema::create('slugs', function($table)
{
$table->engine = 'InnoDB';
$table->string('nameslug');
$table->string('slug')->unsigned()->nullable();
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('slugs');
}
我想要做的是将slugs table 中的*slug column* 添加到files table。
【问题讨论】:
标签: php mysql database laravel octobercms