|
php_sqlsrv_52_ts_vc6.dll (线程安全)
php_sqlsrv_52_nts_vc6.dll (非线程安全)
vc6用于Apache,vc9用于IIS
2.修改php.ini
extension=php_sqlsrv_52_ts_vc6.dll
3.下载sqlncli.msi,微软官方可以下
安装的时候提示是sql server 2008的,不过2005也是可以用的。
4.测试代码
复制代码 代码如下:
<?php
$serverName = "127.0.0.1";
$connectionInfo = array("Database"=>"TestDB","UID"=>"test","PWD"=>"test");
$conn = sqlsrv_connect($serverName, $connectionInfo);
if($conn) {
echo "Connection established.<br>";
} else {
echo "Connection could not be established.<br>";
die(print_r(sqlsrv_errors(), true));
exit();
}
$sql = "select * from T_Employee";
$result = sqlsrv_query($conn,$sql);
$data = array();
while($row=sqlsrv_fetch_array($result)) {
$data[] = $row;
}
foreach($data as $p) {
echo $p['Name']."<br>";
}
sqlsrv_close($conn);
echo "<br> Done <br>";
echo date("Y-m-d h:i:s");
?>
php技术:php下连接mssql2005的代码,转载需保留来源!
郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。