gpt4 book ai didi

php - SQLSTATE[42S02] : Base table or view not found: 1146 Table 'app.articles' doesn't exist (SQL: select * from `articles` )

转载 作者:行者123 更新时间:2023-11-29 07:19:42 28 4
gpt4 key购买 nike

我试图创建我的数据库到 Laravel 应用程序,但收到此错误。我正在关注这个here教程。

我无法访问我的文章数据库,但我可以访问 User.php 预定义模型中的任何内容。

路由.php

use App\article;
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/

Route::get('/', function () {
return view('welcome');
});

Route::get('article', function () {
echo article::all();
});

文章.php

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class article extends Model
{

}

in Connection.php line 673
at Connection->runQueryCallback('select * from `articles`', array(), object(Closure)) in Connection.php line 629
at Connection->run('select * from `articles`', array(), object(Closure)) in Connection.php line 342
at Connection->select('select * from `articles`', array(), true) in Builder.php line 1508
at Builder->runSelect() in Builder.php line 1494
at Builder->get(array('*')) in Builder.php line 596
at Builder->getModels(array('*')) in Builder.php line 303
at Builder->get(array('*')) in compiled.php line 10366
at Model::all() in routes.php line 20
at RouteServiceProvider->{closure}()
at call_user_func_array(object(Closure), array()) in compiled.php line 8415
at Route->runCallable(object(Request)) in compiled.php line 8405
at Route->run(object(Request)) in compiled.php line 8121
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 3176
at VerifyCsrfToken->handle(object(Request), object(Closure))
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9838
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 13274
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9838
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 11822
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9838
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 13009
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9838
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 12946
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9838
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in compiled.php line 9828
at Pipeline->then(object(Closure)) in compiled.php line 8122
at Router->runRouteWithinStack(object(Route), object(Request)) in compiled.php line 8113
at Router->dispatchToRoute(object(Request)) in compiled.php line 8103
at Router->dispatch(object(Request)) in compiled.php line 2400
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 3237
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9838
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in compiled.php line 9828
at Pipeline->then(object(Closure)) in compiled.php line 2347
at Kernel->sendRequestThroughRouter(object(Request)) in compiled.php line 2331
at Kernel->handle(object(Request)) in index.php line 54
at require_once('C:\xampp\htdocs\Laravel_apps\App\public\index.php') in server.php line 21
1/2
PDOException in Connection.php line 333:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'app.articles' doesn't exist
in Connection.php line 333
at PDO->prepare('select * from `articles`') in Connection.php line 333
at Connection->Illuminate\Database\{closure}(object(MySqlConnection), 'select * from `articles`', array()) in Connection.php line 666
at Connection->runQueryCallback('select * from `articles`', array(), object(Closure)) in Connection.php line 629
at Connection->run('select * from `articles`', array(), object(Closure)) in Connection.php line 342
at Connection->select('select * from `articles`', array(), true) in Builder.php line 1508
at Builder->runSelect() in Builder.php line 1494
at Builder->get(array('*')) in Builder.php line 596
at Builder->getModels(array('*')) in Builder.php line 303
at Builder->get(array('*')) in compiled.php line 10366
at Model::all() in routes.php line 20
at RouteServiceProvider->{closure}()
at call_user_func_array(object(Closure), array()) in compiled.php line 8415
at Route->runCallable(object(Request)) in compiled.php line 8405
at Route->run(object(Request)) in compiled.php line 8121
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 3176
at VerifyCsrfToken->handle(object(Request), object(Closure))
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9838
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 13274
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9838
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 11822
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9838
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 13009
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9838
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 12946
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9838
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in compiled.php line 9828
at Pipeline->then(object(Closure)) in compiled.php line 8122
at Router->runRouteWithinStack(object(Route), object(Request)) in compiled.php line 8113
at Router->dispatchToRoute(object(Request)) in compiled.php line 8103
at Router->dispatch(object(Request)) in compiled.php line 2400
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 3237
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9838
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in compiled.php line 9828
at Pipeline->then(object(Closure)) in compiled.php line 2347
at Kernel->sendRequestThroughRouter(object(Request)) in compiled.php line 2331
at Kernel->handle(object(Request)) in index.php line 54
at require_once('C:\xampp\htdocs\Laravel_apps\App\public\index.php') in server.php line 21

最佳答案

在您的模型“article.php”中执行此操作。

namespace App;

use Illuminate\Database\Eloquent\Model;

class Article extends Model
{
protected $table = 'article';
}

它将适用于您的“文章”表。

关于php - SQLSTATE[42S02] : Base table or view not found: 1146 Table 'app.articles' doesn't exist (SQL: select * from `articles` ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36646195/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com