Php 例外情况';PDO异常';带有消息';SQLSTATE[HY000]:一般错误:1接近“1”)&引用;拉维尔
我正在学习Laravel5关于laracast的教程,我发现了这个错误 异常“PDOException”,消息为“SQLSTATE[HY000]:一般错误:1近”): 您在“refresents('id')上有一个输入错误。您的迁移应该如下所示:Php 例外情况';PDO异常';带有消息';SQLSTATE[HY000]:一般错误:1接近“1”)&引用;拉维尔,php,laravel-5,Php,Laravel 5,我正在学习Laravel5关于laracast的教程,我发现了这个错误 异常“PDOException”,消息为“SQLSTATE[HY000]:一般错误:1近”): 您在“refresents('id')上有一个输入错误。您的迁移应该如下所示: <?php use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class Test extends Migratio
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class Test extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('articles', function(Blueprint $table)
{
$table->increments('id');
$table->integer('user_id')->unsigned();
$table->string('title');
$table->text('body');
$table->timestamps();
$table->timestamp('published_at');
$table->foreign('user_id')
->references('id')
->on('users')
->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('articles', function(Blueprint $table){
$table->dropForeign('articles_user_id_foreign');
});
Schema::drop('articles');
}
}
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class Test extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('articles', function(Blueprint $table)
{
$table->increments('id');
$table->integer('user_id')->unsigned();
$table->string('title');
$table->text('body');
$table->timestamps();
$table->timestamp('published_at');
$table->foreign('user_id')
->references('id')
->on('users')
->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('articles', function(Blueprint $table){
$table->dropForeign('articles_user_id_foreign');
});
Schema::drop('articles');
}
}