我有一个用Laravel3制作的工作项目,我必须切换到MSSQL Server(不过不是我说了算,嗅探.)我不理解此数据库类型上的Laravel配置.

I changed the default inside database.php to this 'default' => 'sqlsrv' then I configured the host, database, username, password in the sqlsrv array but then I get this error message:

此扩展需要Microsoft SQL Server 2012本机客户端ODBC驱动程序与SQL Server通信`

经过一些研究,我发现我们需要SQLSRV的PDO,我已经有了版本5.4,在我的phpinfo中,我得到了这个返回pdo_sqlsrv support : enabled,所以它似乎都是正确的,但同时它似乎要求ODBC SQLSRV连接,我真的必须使用它吗?

I would rather connect directly from the Laravel database connection... but even if I need it and I created some ODBC connection to the server, how do I put them inside my configuration? Here is what I have in my configuration (of course the my... is replace by my real details) :

'sqlsrv' => array(
    'driver'   => 'sqlsrv',
    'host'     => 'myServerIP', 
    'database' => 'myDatabase',
    'username' => 'myUsername',
    'password' => 'myPassword',
    'prefix'   => '',
 ),

Any help would be greatly appreciated, the only thing I found close to my problem was this link from the Laravel forum: Laravel query on SQL Server but then it just stop without giving any configurations.

推荐答案

Ahh after a lot more research, I found out that my driver of SQL Server Native Client 10.0 was out of date and not sufficient to connect to a MsSQL Server 2008 with PDO, you need to have at least version 11.0 in order to connect to an SQL Server 2005+

如果你想验证你的驱动程序版本,你可以浏览Control Panel >> Administrative Tools >> Data Sources (ODBC),然后点击Drivers标签,找出你已经安装的SQL Server Native Client.如果你想更新你的驱动程序,根据你的操作系统配置,你可以 Select 下面正确的链接...

SQL Server 2012 Native Client
x86 (32 bits) Package http://go.microsoft.com/fwlink/?LinkID=239647&clcid=0x409
x64 (64 bits) Package http://go.microsoft.com/fwlink/?LinkID=239648&clcid=0x409

Laravel相关问答推荐

在GitHub操作中缺少PHPStan和PHPMD输出,但在本地存在

LaravelEloquent 的模型如何将值从控制器内部的函数传递到Render()

到查询构建器的MySQL查询

将 ID 传递给资源控制器进行编辑

如何使用动态翻译键翻译 Laravel硬编码字符串(还有 1 个错误)..(验证异常类)

Laravel - 出于某种原因,max 打破了我的查询

如何通过单击进入 vs 代码中的类

如何在 laravel 5.2 中显示 500 内部服务器错误页面?

Laravel:Blade foreach 循环 bootstrap 列

如何在 laravel 中使用 str_replace

Eloquent 的集合方法,例如 only 或 except 返回一个空集合

使用'with'时,Laravel belongsTo 返回 null

Laravel 使用 Storage::put 生成唯一 ID

错误:您的要求无法解析为一组可安装的软件包.

Composer 致命错误:声明 Fxp... 必须与第 334 行的 ...AbstractAssetsRepository.php 兼容

Laravel 5 - 为包创建 Artisan 命令

Laravel 5.3 通知 - 仅使用Electron邮件地址通知

如何卸载 Laravel Passport

Laravel 部署……有标准的方式吗?

如何从 PHPUnit 测试设置运行 Laravel 数据库 seeder 机?