我是新来的,有个错误。
当我试图检查我的页面时,会出现以下错误:
QueryException in Connection.php line 651:SQLSTATE[42S02]: Base table or view not found: 1146 Table "scotchbox.likes" doesn't exist (SQL: select "users".*, "users"."name", "projects"."title" from "likes" inner join "users" on "user_id" = "users"."id" inner join "projects" on "project_id" = "projects"."id")
这是我的迁移:

<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateLikesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('likes', function(Blueprint $table){
            $table->increments('id');
            $table->integer('project_id');
            $table->integer('user_id');
            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('likes');
    }
}

我的职责是:
public function activity()
{
    $likes = DB::table('likes')
        ->join('users', 'user_id', '=', 'users.id')
        ->join('projects', 'project_id', '=', 'projects.id')
        ->select('users.*', 'users.name', 'projects.title')
        ->get();

    return view('user.activity', ['likes' => $likes]);
}

我已经回滚了我的迁移,刷新了它们,。。。但这无助于。。。
有人能帮我吗?

最佳答案

您应该在控制台中运行迁移。它在数据库中创建likes表。

php artisan migrate

如果您想了解迁移:http://laravel.com/docs/5.1/migrations

关于php - Connection.php行651中的Laravel QueryException:SQLSTATE [42S02]:找不到基表或 View ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33254674/

10-14 15:24
查看更多