Download the driver, I downloaded is 2.0, download after the installation release program, which has the following files:
PHP Tutorials _pdo_sqlsrv_52_nts.dll
Php_pdo_sqlsrv_52_ts.dll
Php_pdo_sqlsrv_53_nts_vc6.dll
Php_pdo_sqlsrv_53_nts_vc9.dll
Php_pdo_sqlsrv_53_ts_vc6.dll
Php_pdo_sqlsrv_53_ts_vc9.dll
Php_sqlsrv_52_nts.dll
Php_sqlsrv_52_ts.dll
Php_sqlsrv_53_nts_vc6.dll
Php_sqlsrv_53_nts_vc9.dll
Php_sqlsrv_53_ts_vc6.dll
Php_sqlsrv_53_ts_vc9.dll
Sqlserverdriverforphp.chm (manual, English good enough, you can see, hehe)
Sqlserverdriverforphp_license.rtf
Sqlserverdriverforphp_readme.htm (Readme file)
Here is the content in the Readme file, I translate:
Driver files
PHP version
Thread Security
for PHP. dll
Php_sqlsrv_53_nts_vc6.dll
Php_pdo_sqlsrv_53_nts_vc6.dll
5.3
No
Php5.dll
Php_sqlsrv_53_nts_vc9.dll
Php_pdo_sqlsrv_53_nts_vc9.dll
5.3
No
Php5.dll
Php_sqlsrv_53_ts_vc6.dll
Php_pdo_sqlsrv_53_ts_vc6.dll
5.3
Yes
Php5ts.dll
Php_sqlsrv_53_ts_vc9.dll
Php_pdo_sqlsrv_53_ts_vc9.dll
5.3
Yes
Php5ts.dll
Php_sqlsrv_52_nts.dll
Php_pdo_sqlsrv_52_nts.dll
5.2
No
Php5.dll
Php_sqlsrv_52_ts.dll
Php_pdo_sqlsrv_52_ts.dll
5.2
Yes
Php5ts.dll
About the difference between VC6 and VC9, as well as thread-safe and threading-safe
The VC6 version is compiled using the Visual Studio 6 compiler, and if you are using apache+php under Windows, select the VC6 version.
The VC9 version is compiled using the Visual Studio 2008 compiler, and if you are using iis+php under Windows, select the VC9 version.
Non thread safety is not thread safe and does not perform thread security checks at execution time;
Thread safe is threaded, and thread safety checks are carried out to prevent new requirements from running out of system resources in the form of CGI execution that starts a new thread;
Start configuration
I use the Apmserv built PHP environment (Apache 2.2.9+php 5.2.6+mysql 5.1.28), want to use thread-safe, so choose Php_sqlsrv_52_ts.dll and Php_pdo_sqlsrv_52_ Ts.dll.
To start work, first copy the file to the Ext directory under the PHP folder, and then in the configuration file php.ini
Extensions followed by:
; Extension=php_sqlsrv_52_ts.dll
; Extension=php_pdo_sqlsrv_52_ts.dll
Restart Apache again.
The final test is successful, look at the phpinfo sqlsrv
As shown in the picture, this means the connection is successful!! Get to work!
Connecting to a database tutorial
People who have used SQL Server should be aware that SQL Server typically has two authentication methods, one is the local System account authentication (Windows authentication) and the other is the use of user names and passwords (SQL Server Authentication , the second authentication method must enable mixed mode for SQL Server.
1.Windows Authentication Connection Section code snippet
*/
The code is as follows |
Copy Code |
$serverName = "(local)"; $connectionInfo = Array ("Database" => "Test", "connectionpooling" =>false); $conn = Sqlsrv_connect ($serverName, $connectionInfo); if ($conn = = False) { echo "Connection failed! "; Die (Print_r (Sqlsrv_errors (), true)); } |