应用安装时读取表数据时AppServiceProvider中出现错误

时间:2019-03-03 06:28:52

标签: laravel-5 eloquent

在laravel 5.7应用程序中,我在数据库表中保留了一些设置,在我的app / Providers / AppServiceProvider.php中保留了下几行:

class AppServiceProvider extends ServiceProvider
{
    use funcsTrait;

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {

        if ( \Schema::hasTable(with( new Settings)->getTable() ) ) {
            $settingsArray = Settings::getSettingsList(['site_name', 'site_heading', 'noreply_email'], true);
            $site_name     = ($settingsArray['site_name'] ? $settingsArray['site_name'] : '');
            ...
            config(['feed.feeds.main.title' => htmlspecialchars_decode($site_name . ' : ' . $site_heading)]);
            config(['mail.from.name' => htmlspecialchars_decode($site_name . ' support')]);
            ...
        }

但是在生产服务器上安装我的应用程序时出现错误:

 php artisan config:cache
In Connection.php line 664:                                                                                                                                                                           
  SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost' (SQL: select * from information_schema.tables where table_schema = Votes and table_name = vt_settings)  

看起来像hasTable(在某些情况下检查还不够(但是在我的本地环境中还可以)...在这种情况下还有其他检查吗? 如果用hasTable(注释所有块以上,我没有这个错误...

谢谢!

0 个答案:

没有答案