简体   繁体   English

在MacOs Sierra中使用PHP连接到SQL Server:找不到驱动程序

[英]Connect to SQL Server using PHP in MacOs Sierra : Could not find driver

I have an app written in PHP that connects to MySQL. 我有一个用PHP编写的可连接MySQL的应用程序。 One of my customers want to use SQL Server instead. 我的一位客户希望改用SQL Server。 In the past i had a big headache to make PDO connect to SQL Server in a Windows 2008 machine, but now i'm on a Mac with Sierra. 过去,我非常想让PDO在Windows 2008机器上连接到SQL Server,但是现在我在装有Sierra的Mac上。 Is there any 'easy' way to configure this connection, without having to download sources, compile and so on ? 是否有任何“简便”的方法来配置此连接,而无需下载源代码,进行编译等?

By simply using the code below : 通过简单地使用下面的代码:

$dbh = new PDO("sqlsrv:Server=dbserver.domein.com;Database=testdb", "User@dbserver", "Password");

I get the 'Could not find driver' error. 我收到“找不到驱动程序”错误。

Thanks ! 谢谢 !

Making a connection with PDO to an SQL Serve shouldn't be a problem. 使用PDO与SQL Server建立连接应该不是问题。

$dbh = new PDO("sqlsrv:Server=dbserver.domein.com;Database=testdb", "User@dbserver", "Password");

However you should check the query's for some DB Server specific query's. 但是,您应该检查查询中是否有某些特定于DB Server的查询。 While they are both SQL there are still some differences between the two. 虽然它们都是SQL,但两者之间仍然存在一些差异。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM