PHP连接sqlserver (mssql)Class
class sqlservClass{
private $host;
private $name;
private $passwd;
private $db;
private $link;
private $obj;
//public $query;
public $array;
public $result;
function __construct() {
include("mssql.inc.php");
$this->host = $host;
$this->name = $name;
$this->passwd = $passwd;
$this->db = $db;
$this->mssql_Conn();
}
private function mssql_Conn(){
$this->link=mssql_connect($this->host,$this->name,$this->passwd)or die("Links sqlserver server error");
mssql_select_db($this->db, $this->link)or die("Sqlserver database link error");
}
public function ms_Query($query){
$this->result = mssql_query($query,$this->link);
return $this->result;
}
public function ms_ObjList($query){
$this->result = $this->ms_Query($query);
$this->array = array();
while ($this->obj = mssql_fetch_object($this->result)) {
$this->array[] = $this->obj;
}
mssql_free_result( $this->result );
return $this->array;
}
function __destruct() {//destruct
mssql_close($this->link);
}//End destruct
}
|
阅读(754) | 评论(0) | 转发(0) |