在 WAMP 上为 PHP 安装 SQLSRV 扩展

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15709374/
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-08-25 09:47:51  来源:igfitidea点击:

Install SQLSRV extension for PHP on WAMP

phpsql-serverwamp

提问by user1971193

I've seen many of these posts and have looked through them all, but I still cannot get the SQLSRV extension running. Can you help me out? I will post all the information I have below:

我已经看过很多这样的帖子并且已经浏览了所有帖子,但是我仍然无法运行 SQLSRV 扩展。你能帮我吗?我将在下面发布我拥有的所有信息:

  • Windows 7 64-bit
  • WampServer 2.2 32-bit
  • PHP 5.4.3 32-bit
  • Apache 2.2.22 (can't tell if VC6 or VC9)
  • Microsoft SQL Server 2012 Native Client 64-bit
  • 视窗 7 64 位
  • WampServer 2.2 32 位
  • PHP 5.4.3 32 位
  • Apache 2.2.22(不知道是 VC6 还是 VC9)
  • Microsoft SQL Server 2012 本机客户端 64 位

I downloaded SQLSRV30.exe. I extracted the dll files to C:\wamp\bin\php\php5.4.3\ext.

我下载了 SQLSRV30.exe。我将dll文件解压到C:\wamp\bin\php\php5.4.3\ext。

In my php.ini:

在我的 php.ini 中:

  • extension_dir = "c:/wamp/bin/php/php5.4.3/ext/"
  • extension=php_sqlsrv_54_ts.dll
  • extension=php_pdo_sqlsrv_54_ts.dll
  • extension_dir = "c:/wamp/bin/php/php5.4.3/ext/"
  • 扩展名=php_sqlsrv_54_ts.dll
  • 扩展名=php_pdo_sqlsrv_54_ts.dll

I know that SQLSRV30.exe is built as 32-bit. This is why I have 32-bit versions of Wamp and PHP. I also know that nothing in Wamp is non-thread-safe.
If I view phpinfo() I should see a 'sqlsrv' section, but I currently do not.

What am I doing wrong?

我知道 SQLSRV30.exe 是 32 位的。这就是为什么我有 32 位版本的 Wamp 和 PHP。我也知道 Wamp 中没有任何东西是非线程安全的。
如果我查看 phpinfo() 我应该看到一个“sqlsrv”部分,但我目前没有。

我究竟做错了什么?

回答by user3051218

If you are editing c:\wamp\bin\php\php.ini, do not edit that file just edit the one given by wamp server php.ini file, goto wamp server php, then php.ini then you get write ini file.

如果您正在编辑c:\wamp\bin\php\php.ini,请不要编辑该文件,只需编辑 wamp 服务器提供的 php.ini 文件,转到 wamp 服务器 php,然后 php.ini,然后您将获得写入 ini 文件。

I had the same problem, this fixed it for me.

我有同样的问题,这为我解决了。

Also, make sure you right click WAMP shortcut and "Run as Administrator"

另外,请确保右键单击 WAMP 快捷方式并“以管理员身份运行”

回答by André Seppenwoolde

I ran into some trouble this morning, but I found out I had a x64 WampServer... Which was not gonna work correctly.

今天早上我遇到了一些麻烦,但我发现我有一个 x64 WampServer……它不能正常工作。

So, I reinstalled a x86 WampServer, and followed everything i could find on PHP.net (http://php.net/manual/en/sqlsrv.requirements.php). Because I saw this post while i was looking for my x64 solution, I thought I would come back and try to help you:

所以,我重新安装了一个 x86 WampServer,并遵循了我在 PHP.net ( http://php.net/manual/en/sqlsrv.requirements.php)上可以找到的所有内容。因为我在寻找 x64 解决方案时看到了这篇文章,所以我想我会回来帮助你:

1) If you have PHP 5.4.# on Wamp, i bet it's TS,VC9

1) 如果你在 Wamp 上有 PHP 5.4.#,我敢打赌它是 TS,VC9

2) Locate the correct 'php.ini' : mine is NOT in the 'bin/php#' folder, but in the 'bin/apache#' folder (C:\wamp\bin\apache\apache2.2.22\bin\php.ini)

2)找到正确的“php.ini”:我的不在“bin/php#”文件夹中,而是在“bin/apache#”文件夹中(C:\wamp\bin\apache\apache2.2.22\bin\ php.ini)

3) There are 2 SQLSRV driver versions, 2.0 and 3.0 , make sure you have 3.0!

3) 有 2 个 SQLSRV 驱动程序版本, 2.0 和 3.0 ,请确保您有 3.0!

From the looks of it, we have exactly the same Wamp version, so... I'm pretty sure you have to use the 'php_sqlsrv_54_ts.dll' and 'php_pdo_sqlsrv_54_ts.dll'.

从它的外观来看,我们有完全相同的 Wamp 版本,所以......我很确定你必须使用'php_sqlsrv_54_ts.dll'和'php_pdo_sqlsrv_54_ts.dll'。

回答by kishu

Did you see your new dll in your php extensions list? If so, click on it and make sure there is a V by its name. (left click on the hopefully green wamp symbol. php-->php extensions-->name of your dll)

你在你的 php 扩展列表中看到你的新 dll 了吗?如果是这样,请单击它并确保其名称中有一个 V。(左键单击希望绿色的 wamp 符号。php-->php 扩展名--> dll 的名称)

I had a similar problem with php 5.5, SQLSRV31.exe, php_sqlsrv_55_nts.dll and php_sqlsrv_55_ts.dll. Miraculously it worked.

我在 php 5.5、SQLSRV31.exe、php_sqlsrv_55_nts.dll 和 php_sqlsrv_55_ts.dll 上遇到了类似的问题。奇迹般地奏效了。