1
我想用流明查詢我的一個設置數據庫。我創造了這樣的一個配置文件:流明數據庫[xxx]未配置
的config/database.php中
return [
'mysql' => [
'domains' => [
'host' => 'localhost',
'username' => 'root',
'password' => '',
'database' => 'domains'
],
// Other connections here...
'driver' => 'mysql'
]
];
然後我嘗試在我的路線來執行我的查詢這樣的
應用程序/ HTTP/routes.php文件
$app->get('/billing/saved/{id}', function($id){
$data = DB::connection('domains')
->select('select billing_id, nickname
from billing
where user_id = 108649 and billing_id = ?', [$id]);
return response()->json($data);
});
當它被運行時,我收到以下錯誤消息:
InvalidArgumentException in DatabaseManager.php line 238:
Database [domains] not configured.
in DatabaseManager.php line 238
at DatabaseManager->getConfig('domains') in DatabaseManager.php line 157
at DatabaseManager->makeConnection('domains') in DatabaseManager.php line 67
at DatabaseManager->connection('domains') in Facade.php line 210
at Facade::__callStatic('connection', array('domains')) in routes.php line 68
at DB::connection('domains') in routes.php line 68
at Closure->{closure}('1')
at call_user_func_array(object(Closure), array('1')) in Container.php line 502
at Container->call(object(Closure), array('id' => '1')) in Application.php line 1263
at Application->callActionOnArrayBasedRoute(array('1', array(object(Closure)), array('id' => '1'))) in Application.php line 1237
at Application->handleFoundRoute(array('1', array(object(Closure)), array('id' => '1'))) in Application.php line 1211
at Application->handleDispatcherResponse(array('1', array(object(Closure)), array('id' => '1'))) in Application.php line 1163
at Application->Laravel\Lumen\{closure}() in Application.php line 1390
at Application->sendThroughPipeline(array(), object(Closure)) in Application.php line 1164
at Application->dispatch(null) in Application.php line 1104
at Application->run() in index.php line 28
我在做什麼不正確?
沒有真正使用流明,但通過一些快速閱讀,應該'mysql'字符串'連接'和'驅動程序'行在'域'內? –
經過一番測試,看起來好像修復了它 –