相关疑难解决方法(0)

未找到基准表或视图:1146表Laravel 5

我尝试使用Laravel 5将数据保存到mysql时出现此错误,其他表单和save()方法工作正常,但这一个:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'sistemal5.cotizacions' doesn't exist (SQL: insert into `cotizacions` (`customer_id`, `total`, `updated_at`, `created_at`) values (1501, 150.69, 2015-05-11 03:16:25, 2015-05-11 03:16:25))
Run Code Online (Sandbox Code Playgroud)

这是我的Controller存储方法:

public function store(CotFormRequest $request)
    {    
        $quote = new Cotizacion;
        $quote->customer_id = Input::get('data.clientid');
        $quote->total = Input::get('data.totalAftertax');    
        $quote->save();    
    }
Run Code Online (Sandbox Code Playgroud)

这是我的模型:

<?php namespace App\Models\Cotizacion;

use Illuminate\Database\Eloquent\Model;


class Cotizacion extends Model {

}
Run Code Online (Sandbox Code Playgroud)

我必须忽略一些非常明显的东西,因为我无法理解为什么Laravel正在添加一个"S"表格是cotizacion而不是cotizacions.

我怎么解决这个问题?

php mysql laravel

39
推荐指数
3
解决办法
10万
查看次数

无法启动Laravel,我得到"Base table or view not found"错误

首先我错误地回滚了2次迁移,然后我运行php artisan migrate命令,我收到以下错误:

[Illuminate\Database\QueryException] SQLSTATE[42S02]: Base table or view not found: 1146 Table 'exercise1.categories' doesn't exist (SQL: select * from categories where parent_id = 0) [PDOException] SQLSTATE[42S02]: Base table or view not found: 1146 Table 'exercise1.categories' doesn't exist

然后我停止了拉拉维尔.之后,当我运行php artisan serve启动Laravel 的命令时,我得到了同样的错误.以下是我已回滚的2次迁移:

1.

class CreateCategoriesTable extends Migration
    {

        public function up()
        {
            Schema::create('categories',function (Blueprint $table){
                $table->increments('id');
                $table->string('name');
                $table->text('parent_id');
                $table->timestamps();
        });
        }
        public function down()
        {
            Schema::dropIfExists('categories');
        }
    }
Run Code Online (Sandbox Code Playgroud)

2.

class CreateArticlesTable extends Migration
    {
        public function …
Run Code Online (Sandbox Code Playgroud)

php laravel laravel-migrations

9
推荐指数
1
解决办法
6435
查看次数

Laravel 5.3 查询数据库并将其传递给所有视图

我有一些我想从数据库中获取的动态数据并将其传递给所有视图。我试图从互联网上举一些例子,但它们似乎在我的情况下不起作用

public function boot(){}
Run Code Online (Sandbox Code Playgroud)

我无法对其进行数据库查询,只能传递硬编码值。我尝试过的另一种方法是使用基本控制器,但是在访问变量时视图给了我错误

$query = DB::table('users')->first();
\View::share('user', $query);
Run Code Online (Sandbox Code Playgroud)

任何人都有基于 BaseController 的解决方案将不胜感激,如果我错过了什么请提醒我

php laravel laravel-5 laravel-5.3

2
推荐指数
1
解决办法
1665
查看次数

SQLSTATE[42S02]:未找到基表或视图:1146 表“prj_roocket.permissions”不存在

我创建一个迁移

Schema::create('roles', function (Blueprint $table) {
        $table->increments('id');
        $table->string('name');
        $table->string('label')->nullable();
        $table->timestamps();
    });

    Schema::create('permissions', function (Blueprint $table) {
        $table->increments('id');
        $table->string('name');
        $table->string('label')->nullable();
        $table->timestamps();
    });

    Schema::create('permission_role', function (Blueprint $table) {
        $table->integer('role_id')->unsigned();
        $table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade');

        $table->integer('permission_id')->unsigned();
        $table->foreign('permission_id')->references('id')->on('permissions')->onDelete('cascade');

        $table->primary(['role_id' , 'permission_id']);
    });

    Schema::create('role_user', function (Blueprint $table) {
        $table->integer('role_id')->unsigned();
        $table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade');

        $table->integer('user_id')->unsigned();
        $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');

        $table->primary(['role_id' , 'user_id']);
    });
Run Code Online (Sandbox Code Playgroud)

我在 CMD 中写的任何内容php artisan migrate and composer dumpautoload and php artisan serve and...都会看到此错误。我也删除了数据库并创建了一个新数据库。

[Illuminate\Database\QueryException] SQLSTATE[42S02]:未找到基表或视图:1146 表“prj_roocket.permissions”不存在(SQL:select * from permissions

[PDOException] SQLSTATE[42S02]:未找到基表或视图:1146 表“prj_roocket.permissions”不存在

php laravel

1
推荐指数
1
解决办法
9887
查看次数

未找到Laravel基表或视图

我的routes.php我有以下内容:

<?php

Route::group(array(), function () {
    View::share('roots', Category::roots()->get());
    $tree = Category::get()->toHierarchy()->toArray();
    View::share('categories', $tree);

    Route::get('/', array('as' => 'home', 'uses' => 'HomeController@index'));
});
Run Code Online (Sandbox Code Playgroud)

当我的数据库还没有表,我想做php artisan migrate时,结果是:SQLSTATE [42S02]:找不到基表或视图:1146表'ae_dev.categories'不存在

我的迁移文件:

<?php

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

class CreateCategoriesTable extends Migration {

  /**
   * Run the migrations.
   *
   * @return void
   */
  public function up() {
    Schema::create('categories', function(Blueprint $table) {
      $table->increments('id');
      $table->integer('parent_id')->nullable()->index();
      $table->integer('lft')->nullable()->index();
      $table->integer('rgt')->nullable()->index();
      $table->integer('depth')->nullable();
      $table->string('name', 255);

      $table->timestamps();
    });
  }

  /**
   * Reverse the migrations.
   *
   * @return void
   */
  public function down() {
    Schema::drop('categories');
  } …
Run Code Online (Sandbox Code Playgroud)

php laravel laravel-4 laravel-routing

0
推荐指数
1
解决办法
3331
查看次数