标签:io os ar for strong sp 文件 div on
今天遇到php连接mssql问题,按照网上各种尝试,最后成功,再此记录下。由于 php 5.3以后就不支持mssql。要下载相应的The SQL Server Driver for PHP。现在微软官网有两个安装包:SQLSRV20.exe 和 SQLSRV30.exe
说下这两个安装包,20中有:
Driver file
PHP version
Thread safe?
Use with 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_vc6.dll
php_pdo_sqlsrv_52_nts_vc6.dll
5.2
no
php5.dll
php_sqlsrv_52_ts_vc6.dll
php_pdo_sqlsrv_52_ts_vc6.dll
5.2
yes
php5ts.dll
30中有:
Driver file
PHP version
Thread safe?
Use with PHP .dll
php_sqlsrv_53_nts.dll
php_pdo_sqlsrv_53_nts.dll
5.3
no
php5.dll
php_sqlsrv_53_ts.dll
php_pdo_sqlsrv_53_ts.dll
5.3
yes
php5ts.dll
php_sqlsrv_54_nts.dll
php_pdo_sqlsrv_54_nts.dll
5.4
no
php5.dll
php_sqlsrv_54_ts.dll
php_pdo_sqlsrv_54_ts.dll
5.4
yes
php5ts.dll
其中52对应的php5.2的,vc9对应你的php 包的格式,例如(php-5.3.27-Win32-VC9-x86.zip) 。ts和nts的区别大家应该都知道的,也是要和你的php版本要对应的。
还有一点要注意就是下面这个说明,如果你下载的对应的php的diver是30.exe 的那你同时要安装Microsoft SQL Server 2012 Native Client。
Version 3.0 of the driver requires Microsoft SQL Server 2012 Native Client. You can download Microsoft SQL Server 2012 Native Client from theSQL Server 2012 feature pack page.
Version 2.0 of the driver requires Microsoft SQL Server 2008 R2 Native Client. Click on the appropriate link below:
Download the X86 package
Download the X64 package
解压sql Driver 包后要放到PHP的目录下,同时增加
extension=php_pdo_mssql.dll
extension=php_pdo_sqlsrv_53_ts_vc9.dll
extension=php_sqlsrv_53_ts_vc9.dll
extension=ntwdblib.dll
这了还有一个重要的dll文件就是ntwdblib.dll文件,大家可以相应的去下载对应的sql版本的,每个版本不一样,csdn上有下载的
sql 2005 对应编号 2000.80.194.0,sql 2008 对应编号 2000.80.2039.0。
下载ntwdblib.dll放到php的目录下或者直接放在system32下。
重启启动apache服务器,php.info中显示如下界面:
说明sql配置已经成功。
一下是测试方法:
<?php
$serverName="(localhost)";
$connectionInfo=array("Database"=>"dbName","UID"=>"user","PWD"=>"pwd");
$conn=sqlsrv_connect($serverName,$connectionInfo);
if($conn){
echo"连接成功.<br/>";
}else{
echo"连接失败.<br/>";
die(print_r(sqlsrv_errors(),true));
}
?>
php 5.3.27 访问 Sql2008 和 sql 2005
标签:io os ar for strong sp 文件 div on
原文地址:http://www.cnblogs.com/seoyouhua/p/4039350.html