Laravel 连接到 sql server

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23008924/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 09:21:01  来源:igfitidea点击:

Laravel connection to sql server

sqlsql-serverlaravellaravel-4

提问by user3185936

Trying to connect laravel to my local sql server 2012. But getting error:

尝试将 laravel 连接到我的本地 sql server 2012。但出现错误:

enter image description here

在此处输入图片说明

This is the config file in laravel:

这是laravel中的配置文件:

'sqlsrv' => array(
            'driver'   => 'sqlsrv',
            'host'     => 'localhost',
            'database' => 'nih_bw',
            'username' => 'sa',
            'password' => 'root',
            'prefix'   => '',
        ),

回答by hannesvdvreken

I think you need to install the PDO driver for MS SQL Server:

我认为您需要为 MS SQL Server 安装 PDO 驱动程序:

http://pecl.php.net/package/PDO_DBLIB

http://pecl.php.net/package/PDO_DBLIB

Install with the command:

使用以下命令安装:

pecl install PDO_DBLIB

If you are developing on a Windows machine:

如果您在 Windows 机器上开发:

http://pecl.php.net/package/pdo_sqlsrv

http://pecl.php.net/package/pdo_sqlsrv

Install with:

安装:

pecl install pdo_sqlsrv

回答by Raheel Hasan

on windows, you will need to install pdo_sqlsrvfrom http://php.net/manual/en/ref.pdo-sqlsrv.php

在 Windows 上,您需要pdo_sqlsrvhttp://php.net/manual/en/ref.pdo-sqlsrv.php安装