Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
438 views
in Technique[技术] by (71.8m points)

sql server - PHP on IIS7 with (PDO) MS-SQL support

I'm running an IIS 7 windows server and a relevant part of my phpinfo's configure command currently reports this:

cscript /nologo configure.js ...... "--without-mssql" "--without-pdo-mssql" "--without-pi3web" ...... "--with-mcrypt=static"

What do I need to do to my server so that I can see the with-mssql above as opposed to seeing without-mssql?

I was once told to recompile PHP. That's where the buck stopped. Cause this PHP came with IIS install so we never needed to compile PHP before. Re-compiling... is that a command line thing?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Microsoft SQL Server support and extensions are not shipped with PHP anymore. To connect PHP with SQL Server you need Microsoft Drivers for PHP for SQL Server:

The Microsoft Drivers for PHP for SQL Server is a PHP 5 extension that provides data access to SQL Server 2005 and later versions including SQL Azure.

The download page for drivers lists four versions to choose from. Consult the System Requirements page in order to determine which version you need. You must install the correct driver for your Operating System+SQL Server+PHP version combination.

You will also need one of these depending on which driver you choose (these must be installed separately):

  • SQL Server Native Client
  • Microsoft ODBC Driver 11 for SQL Server

The installer simply extracts the files in the specified location. You must the files to PHP extensions directory. The files are PHP extensions. The file names indicate:

  • nts/ts -- should be used with non thread safe/thread safe version of PHP
  • 54/55/56... -- should be used with PHP version 5.4, 5.5, 5.6, ...
  • sqlsrv/pdo_sqlsrv -- provides procedural interface/PDO interface

Enable the extensions in php.ini file making sure that thread safetyness and PHP versions match.

Check phpinfo to see if extensions are loaded. Test sqlsrv_connect("servername") and new PDO("sqlsrv:server=servername") to make sure the extensions are working.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...