我有一个搜索功能为我的数据库,但有时我收到此消息:
[2016-02-04 07:03:18] local.ERROR: PDOException: sqlSTATE[HY000] [1044] Access denied for user ''@'localhost' to database 'forge' in C:\xampp\htdocs\reko\api\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.PHP:55 Stack trace: #0 C:\xampp\htdocs\reko\api\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.PHP(55): PDO->__construct('MysqL:host=loca...','forge','',Array) ...@H_301_2@在十个调用之一中,我收到了500条错误消息,但我不知道为什么.其他电话会给出正确的结果.
.ENV
APP_ENV=local APP_DEBUG=true APP_KEY=bJM6O0MnrIPaTNwKKOqNJkGinRDv1fnc DB_HOST=localhost DB_DATABASE=reko DB_USERNAME=root DB_PASSWORD= CACHE_DRIVER=file SESSION_DRIVER=file QUEUE_DRIVER=sync@H_301_2@public function search(Modul $modul,Request $request) { $question = Question::whereModulId($modul->id) ->where('value','LIKE','%' . $request->get('keywords') . '%') ->with('tags') ->whereHas('exams',function ($query) use ($request) { $query->where('date','>=',$request->get('year').'-01-01'); }); if (!$request->get('parent')) $question->where('type','<>','parent'); if (!$request->get('own')) $question->where('type','own'); if (!$request->get('normal')) $question->where('type','normal'); if ($request->get('answered')) $question->has('answers'); return $question->paginate(10); }@H_301_2@为database.PHP
'MysqL' => [ 'driver' => 'MysqL','host' => env('DB_HOST','localhost'),'database' => env('DB_DATABASE','forge'),'username' => env('DB_USERNAME','password' => env('DB_PASSWORD',''),'charset' => 'utf8','collation' => 'utf8_unicode_ci','prefix' => '','strict' => false,],@H_301_2@