php怎么链接sqlserver数据库进行增删改查
1个回答
展开全部
php有专门的sql server操作函数,举个简单的例子,是查询的
$serverName = "localhost"; //数据库服务器地址
$uid = "root"; //数据库用户名
$pwd = "123456"; //数据库密码
$connectionInfo = array("UID"=>$uid, "PWD"=>$pwd, "Database"=>'databasename');
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn == false){
echo "连接数据库失败!";
die( print_r( sqlsrv_errors(), true));
}
$sql = "select * from user";
$query = sqlsrv_query( $conn, $sql , array(), array( "Scrollable" => SQLSRV_CURSOR_KEYSET ));
$num_rows = sqlsrv_num_rows($query);
if($num_rows > 0){
while ($row = sqlsrv_fetch_array($query)){
echo $row['aaaa'];
}
}
其它的操作也同理,举一反三
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询