如何从PHP应用程序连接和查询本地和远程Microsoft SQL Server? [英] How to connect and query a local and remote Microsoft SQL Server from a PHP application?
问题描述
我一直试图(徒劳地)使用Microsoft发布的SQL Server PHP驱动程序连接到Microsoft SQL Server 2005/2008.我必须安装本机客户端,PHP驱动程序,然后编辑php.ini文件.瞧,它会连接但会喊出错误(这是一个愚蠢的数组,其中包含一个条目,上面写着)要求Native Client.我已经安装了1.0版和1.1版(并尝试连接单独的安装),但徒劳无功.
有人可以指出我要去哪里了吗? :-(
另外,如何从在LAMP环境中运行的PHP应用程序查询远程托管的SQL Server?我没有使其正常工作,所以我改用了mssql扩展名.
您是否看过 mssql [ FreeTDS [ ^ ].
我只有使用mssql扩展名连接到IIS服务器上的MSSQL DB的经验.我遇到的唯一(主要)问题是C:\Windows
文件夹中缺少几个dll,尤其是ntwdblib.dll. C:\inetpub\php\ext
文件夹中也缺少php_mssql.dll
.将dll放置在正确的位置后,我要做的就是更新我的php.ini
文件,并且该文件可以正常工作.
希望有帮助.
I have been trying (in vain) to connect to Microsoft SQL Server 2005/2008 using the PHP Driver for SQL Server released by Microsoft. I had to install the Native Client, the PHP Driver, edit the php.ini file. And voila, it connects but shouts an error (which is a stupid array with one of the entries which says) Native Client is required. I have installed both versions 1.0 and 1.1 (and tried connecting with separate installations as well) but in vain.
Can somebody point out where I''m going wrong? :-(
Also, how do you query a remotely hosted SQL Server from a PHP application that is running on a LAMP environment?
I did try the native client a while ago and I didn''t get it to work, so I got the mssql extension working instead.
Have you looked into the mssql[^] extension for PHP? The alternative is FreeTDS[^].
I only have experience connecting to an MSSQL DB on an IIS server with the mssql extension. The only (major) problem I had with it was that a couple of dll''s were missing from theC:\Windows
folder, ntwdblib.dll in particular.php_mssql.dll
was also missing fromC:\inetpub\php\ext
folder. After I put the dll''s in the right place all I had to do was update myphp.ini
file an it worked.
Hope that helps.
这篇关于如何从PHP应用程序连接和查询本地和远程Microsoft SQL Server?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!