Laravel 5.4連線MS SQL Server方式

1. config/database.php 新增
[code]
// 2017.04.05 by lin shou shan
‘sqlsrv’ => [
‘driver’ => ‘sqlsrv’, //
‘host’ => ‘localhost\sqlexpress’, // 資料庫位置及別名
‘username’ => ‘sa’, //密號
‘password’ => ”, //密碼
‘database’ => ”, //資料庫
‘prefix’ => ”,
],
[/code]
2..env修改
DB_CONNECTION=sqlsrv

3.route,web.php測試
Route::get(‘/’, function () {
var_dump( DB::table(‘tablename’)->first() );
});