"fff","ConnectionPooling"=>'','UID'=>'sa','PWD ..."/> "fff","ConnectionPooling"=>'','UID'=>'sa','PWD ...">
安装好php的sqlsrv模块
//本地连接
$serverName = "CX95DLISVW4C6TK\aaa";//计算机名\实例名
$connectionInfo = array("Database"=>"fff","ConnectionPooling"=>'','UID'=>'sa','PWD'=>'123');
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn == false)
{
echo "连接失败!";
die( print_r( sqlsrv_errors(), true));
}else{
echo "dfdf";
$query=sqlsrv_query($conn,"select * from dbo.fdsf");
while($row = sqlsrv_fetch_array($query)){
print_r($row);
}
//print_r($query);
}
//远程连接
$serverName = "192.168.1.5";
$connectionInfo = array("Database"=>"CIA","ConnectionPooling"=>'','UID'=>'sa','PWD'=>'360kad.com');
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn == false)
{
echo "连接失败!";
die( print_r( sqlsrv_errors(), true));
}else{
echo "dfdf";
$query=sqlsrv_query($conn,"select * from CodeSiteTaker_Model");
while($row = sqlsrv_fetch_array($query)){
print_r($row);
}
//print_r($query);
}