php连接mssql查询不会写,删除添加修改都好使,求帮忙 50
<?phpclassmodelmssql{private$link;private$conn;function__construct(){$serverName="111...
<?php
class modelmssql
{
private $link;
private $conn;
function __construct()
{
$serverName = "111.11.11.11.111";
$database = "db";
$uid = "ming";
$pwd = "mi";
try {
$this->conn = new PDO( "sqlsrv:server=$serverName;Database = $database", $uid,
$pwd);
$this->conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
}
catch( PDOException $e ) {
die( "Error connecting to SQL Server".$e );
}
}
//删除
public function sc($a=0)
{
$sql="delete from table where 电话='$a';";
$res=$this->conn->exec($query);
return $a;
}
//查询
public function cha()
{
$sql="select * from table;";
$tt=mssql_query($sql,$this->link);
$arr=array();
while ($row=mssql_fetch_array($tt))行一下
{
$arr[]=$row;
}
return $arr;
} 展开
class modelmssql
{
private $link;
private $conn;
function __construct()
{
$serverName = "111.11.11.11.111";
$database = "db";
$uid = "ming";
$pwd = "mi";
try {
$this->conn = new PDO( "sqlsrv:server=$serverName;Database = $database", $uid,
$pwd);
$this->conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
}
catch( PDOException $e ) {
die( "Error connecting to SQL Server".$e );
}
}
//删除
public function sc($a=0)
{
$sql="delete from table where 电话='$a';";
$res=$this->conn->exec($query);
return $a;
}
//查询
public function cha()
{
$sql="select * from table;";
$tt=mssql_query($sql,$this->link);
$arr=array();
while ($row=mssql_fetch_array($tt))行一下
{
$arr[]=$row;
}
return $arr;
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询