【发布时间】:2018-06-26 11:38:50
【问题描述】:
我在创建和迁移数据透视表时遇到了这些错误。 这是我的数据透视表代码。
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class HotelUserTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('hotel_user', function (Blueprint $table) {
$table->integer('hotel_id')->unsigned();
$table->integer('user_id')->unsigned();
$table->foreign('hotel_id')->refrences('id')->on('hotels');
$table->foreign('user_id')->refrences('id')->on('users');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('hotel_user');
}
}
在 Connection.php 第 664 行:
SQLSTATE[42000]:语法错误或访问冲突:1064 您的 SQL 语法有错误;检查手册 对应于您的 MariaDB 服务器版本,以便在第 1 行的 ')' 附近使用正确的语法(SQL:alter table
hotel _useradd constrainthotel_user_hotel_id_foreignforeign key (hotel_id) referenceshotels())
在 Connection.php 第 452 行:
SQLSTATE[42000]:语法错误或访问冲突:1064 您的 SQL 语法有错误;检查手册 对应于您的 MariaDB 服务器版本,以便在第 1 行的 ')' 附近使用正确的语法
【问题讨论】:
-
代码图像对您没有帮助
-
欢迎来到 Stack Overflow! Please don't post your code as an image.
-
我强烈推荐阅读Writing the Perfect Question,尤其是“拼写、语法和格式”部分。我已经更正了这篇文章,并修复了一些常见错误,但在以后的文章中阅读这篇文章将大大有助于为未来的访问者制作高质量的文章。
-
看我的回答。它的错字参考
标签: php mysql laravel laravel-5.5