【问题标题】:Laravel - Request error on serverLaravel - 服务器上的请求错误
【发布时间】:2016-06-09 08:09:51
【问题描述】:

我正在尝试在服务器上获取 Laravel 项目;在本地一切正常,我将所有文件发送到服务器,更改了 routes.php 和 .env 以便一切正常(数据库、查询、路由...)。

我在反向代理后面工作,但让路由正常工作不是问题。

我可以登录,但我无法访问或执行使用数据库的任何内容(登录除外)。

示例:

控制器:

public function show($id) {
   $compte = Compte::find($id);
   $suiviFormation = User_formation::join('formation', 'formation.id_formation', '=', 'user_formation.id_formation')
                                            ->join('type_formation', 'formation.id_type_formation', '=', 'type_formation.id_type_formation')
                                            ->where('id_compte', $id)
                                            ->where(function($query){
                                                $query->where('formation.id_organisme', 1)
                                                        ->orWhere('formation.id_organisme', Auth::user()->id_organisme);
                                            })
                                            ->where('valide', 1)
                                            ->orderBy('type_formation.nom',  'asc')
                                            ->orderBy('formation.nom',  'asc')
                                            ->orderBy('date_formation',  'desc')
                                            ->get();
        $formations = array();
        $types = array();

        foreach($suiviFormation as $suivi){
            $formations[] = Formation::find($suivi->id_formation);
        }

        foreach($formations as $formation){
            $types[$formation->id_type_formation] = $formation->type_formation->nom;
        }   


        $userPoste = User_Poste::where('id_compte', $id)
            ->where('date_fin', null)
            ->first();


        $formationsAvailable = Formation::select('formation.id_type_formation', 'formation.nom', 'formation_importance.importance')
                                            ->join('formation_importance', 'formation_importance.id_formation', '=', 'formation.id_formation')
                                            ->join('poste', 'poste.id_poste', '=', 'formation_importance.id_poste')
                                            ->where('formation_importance.id_poste', $userPoste->id_poste)
                                            ->where('importance', '!=', 1)
                                            ->orderBy('formation.nom', 'asc')
                                            ->groupBy('formation.id_formation')
                                            ->get();

        return view('formation/formation_show', ['compte' => $compte, 'types' => $types, 'suiviFormation' => $suiviFormation,
            'formations' => $formations, 'formationsAvailable' => $formationsAvailable]);
    }

错误:

QueryException in Connection.php line 624: SQLSTATE[42S02]: Base table or view not found: 
1146 Table 'greement.Formation' doesn't exist 
(SQL: select * from `Formation` where `Formation`.`id_formation` = 61 limit 1)

每一个错误看起来都像这样。


知道与数据库的连接的一部分在工作,其他页面怎么能不工作?

.env:

APP_ENV=local
APP_DEBUG=true
APP_KEY= appkey
DB_HOST= database.host
DB_DATABASE=greement
DB_USERNAME=user
DB_PASSWORD=*******
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

编辑:我没有直接访问服务器的权限,我只能对数据库使用 FTP 和 phpMyAdmin。

【问题讨论】:

    标签: php sql apache laravel


    【解决方案1】:

    您的服务器上的数据库中没有表。您需要使用 php artisan migrate 命令运行迁移,该命令将为您创建表。或者,您可以从数据库转储文件恢复服务器上的数据库数据。

    【讨论】:

    • 我无法直接访问服务器,因此无法执行此操作。我将尝试恢复数据库(有问题添加)。谢谢
    • 从 .sql 文件恢复数据库日期并没有解决问题,我仍然遇到同样的错误。另外,我在数据库中确实有表格,因为如果我没有,我就无法登录网站。
    • 你想告诉我你有Formation 表但仍然得到完全相同的错误?如果不是,请使用 phpMyAdmin 检查表名是否与 Laravel 尝试使用的完全相同。
    • 在本地数据库上,我有formation,效果很好。在服务器数据库上,我确实有同一张表,我将其重命名为 Formation 以尝试它是否改变了某些内容。我确实知道Table 'greement.User_qual_ops' doesn't exist 是一个错误。我只是在写此评论时意识到错误已经改变。我将尝试重命名所有表。我只是想知道为什么它需要在服务器上进行此更改,因为它不关心本地数据库。
    猜你喜欢
    • 1970-01-01
    • 2015-04-02
    • 2019-02-19
    • 2020-11-29
    • 2019-08-18
    • 2017-10-31
    • 1970-01-01
    • 2016-04-21
    • 1970-01-01
    相关资源
    最近更新 更多