【问题标题】:Access violation 1064 error while migrating pivot table [duplicate]迁移数据透视表时出现访问冲突 1064 错误 [重复]
【发布时间】: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 _user add constraint hotel_user_hotel_id_foreign foreign key (hotel_id) references hotels ())

在 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


【解决方案1】:

检查参考文献的拼写

引用更改为引用

【讨论】:

    猜你喜欢
    • 2018-02-06
    • 2018-06-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-19
    • 2017-11-05
    • 2017-08-25
    • 2014-01-07
    相关资源
    最近更新 更多