SQLSTATE [42S02]:找不到基表或视图:1146表'products.all_category'不存在(SQL:从all_countries中选择*)

时间:2018-08-03 15:30:56

标签: laravel laravel-5 laravel-4 laravel-5.2 laravel-5.1

 'mysql' => [
        'driver' => 'mysql',
        'host' => env('DB_HOST', '127.0.0.1'),
        'port' => env('DB_PORT', '3306'),
        'database' => env('DB_DATABASE', 'forge'),
        'username' => env('DB_USERNAME', 'forge'),
        'password' => env('DB_PASSWORD', ''),
        'unix_socket' => env('DB_SOCKET', ''),
        'charset' => 'utf8mb4',
        'collation' => 'utf8mb4_unicode_ci',
        'prefix' => '',
        'strict' => true,
        'engine' => null,
    ],
    'mysql2' => [
        'driver' => 'mysql',
        'host' => env('DB_HOST_2', '127.0.0.1'),
        'port' => env('DB_PORT_2', '3306'),
        'database' => env('DB_DATABASE_2', 'forge'),
        'username' => env('DB_USERNAME_2', 'forge'),
        'password' => env('DB_PASSWORD_2', ''),
        'unix_socket' => env('DB_SOCKET', ''),
        'charset' => 'utf8mb4',
        'collation' => 'utf8mb4_unicode_ci',
        'prefix' => '',
        'strict' => true,
        'engine' => null,
    ],

products是默认数据库,all_category是第二个数据库中名为category的表名,它甚至不能标识第二个数据库类别,它在配置时仅采用第一个默认值,这是控制器内部的查询:-

$users = DB::connection('mysql2')->table("all_category")->get(); 

任何帮助将不胜感激,在此先感谢

1 个答案:

答案 0 :(得分:1)

请尝试使用此工匠命令清除配置缓存:

php artisan config:clear 
php artisan cache:clear 
composer dump-autoload