使用SQL Server驱动程序通过PDO连接到SQL Server [英] Connect to SQL Server through PDO using SQL Server Driver

查看:74
本文介绍了使用SQL Server驱动程序通过PDO连接到SQL Server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Microsoft提供的驱动程序.

我看过使用odbc,dblib,mssql等的示例,但是我相信这些驱动程序的连接字符串应使用'sqlsrv'?

I have seen examples using odbc, dblib, mssql, etc., however I believe the connection string with these drivers should use 'sqlsrv'?

有没有很好的例子来说明如何正确地做到这一点?如果我应该通过其他方法进行此操作,请告诉我.谢谢!

Are there any good examples of how to properly do this? If I should be doing this via some other method please let me know. Thanks!

推荐答案

PDO最好的部分是访问任何数据库都非常容易.前提是您已经安装了这些驱动程序,那么您应该能够做到:

Well that's the best part about PDOs is that it's pretty easy to access any database. Provided you have installed those drivers, you should be able to just do:

$db = new PDO("sqlsrv:Server=YouAddress;Database=YourDatabase", "Username", "Password");

这篇关于使用SQL Server驱动程序通过PDO连接到SQL Server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆