gpt4 book ai didi

php - 如何列出 Laravel 5 中的数据库连接?

转载 作者:行者123 更新时间:2023-11-29 01:37:27 25 4
gpt4 key购买 nike

如何在 Laravel 中获取数据库连接列表。我打算将连接名称加载到选择框中。

'connections' => [
'sqlsrv_auth' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', 'SQLEXPRESS'),
'database' => env('DB_DATABASE', 'auth_db'),
'username' => env('DB_USERNAME', 'sa'),
'password' => env('DB_PASSWORD', '1234'),
'charset' => 'utf8',
'prefix' => '',
],
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', 'SQLEXPRESS'),
'database' => env('DB_DATABASE', 'main_db'),
'username' => env('DB_USERNAME', 'sa'),
'password' => env('DB_PASSWORD', '1234'),
'charset' => 'utf8',
'prefix' => '',
],
'sqlsrv_bpb' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', '192.168.1.1'),
'database' => env('DB_DATABASE', 'mirror'),
'username' => env('DB_USERNAME', 'sa'),
'password' => env('DB_PASSWORD', '1234'),
'charest' => 'utf8',
'prefix' => '',
]

],

最佳答案

知道了..

use Config;

public function test() {
print_r(Config::get('database'));
}

关于php - 如何列出 Laravel 5 中的数据库连接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36975584/

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