在我的数据库配置文件中 - 可能是app / config / database.php。
'connections' => [
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', '192.168.0.5'),//'ADMINRG-2UH26BG', // Provide IP address here
'database' => env('DB_DATABASE', 'VHPDEV'),
'username' => env('DB_USERNAME', 'sa'),
'password' => env('DB_PASSWORD', 'Dbp@2013'),
'prefix' => '',
],
'sqlsrv2' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', '192.168.0.5'),//'ADMINRG-2UH26BG', // Provide IP address here
'database' => env('DB_DATABASE', 'OCSDB'),
'username' => env('DB_USERNAME', 'sa'),
'password' => env('DB_PASSWORD', 'Dbp@2013'),
'prefix' => '',
],
],
.ENV
DB_CONNECTION=sqlsrv
DB_HOST=192.168.0.5
DB_PORT=3306
DB_DATABASE=VHPDEV
DB_USERNAME=sa
DB_PASSWORD=Dbp@2013
查询
DB::connection('sqlsrv')->table('B14SILHOLD')->get();
答案 0 :(得分:1)
你可以通过运行命令来清除laravel的缓存,例如: - php artisan config:cache并尝试执行它。 还要记住检查您的数据库是否在您使用它的模型中定义,或者只是放置\ DB :: connection('sqlsrv') - > table('B14SILHOLD') - > get();