PDOException::(“” SQLSTATE [42000]:语法错误或访问冲突:1064年 您的SQL语法有误;检查与您的马对应的手册 riaDB服务器版本,用于在l的delete CASCADE上的')附近使用正确的语法 ine 1“)
C:\xampp\htdocs\projek\vendor\laravel\framework\src\Illuminate\Database\Connection.php:452
PDO :: prepare(“ alter table
pengerjaan
添加约束pengerjaan_id_kateg ori_foreign
外键(id_kategori
)引用kategori
()删除CASC ADE”)
C:\xampp\htdocs\projek\vendor\laravel\framework\src\Illuminate\Database\Connection.php:452
public function up(){
Schema::create('pengerjaan', function (Blueprint $table) {
$table->increments('id');
$table->unsignedinteger('id_kategori');
$table->unsignedinteger('id_pelanggan');
$table->enum('status', array('proses', 'pending', 'hasil'));
$table->datetime('apply_date');
$table->timestamps();
$table->foreign('id_kategori')->refrences('id')->on('kategori')->onDelete('CASCADE');
$table->foreign('id_pelanggan')->refrences('id')->on('pelanggan')->onDelete('CASCADE');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('pengerjaan');
}
答案 0 :(得分:0)
您有一个拼写错误,它不是refrences
,而是references
,因此请更改以下两行:
$table->foreign('id_kategori')->refrences('id')->on('kategori')->onDelete('CASCADE');
$table->foreign('id_pelanggan')->refrences('id')->on('pelanggan')->onDelete('CASCADE');
与此:
$table->foreign('id_kategori')->references('id')->on('kategori')->onDelete('cascade');
$table->foreign('id_pelanggan')->references('id')->on('pelanggan')->onDelete('cascade');