php mssql 数据库连接类代码
来源:未知
时间:2014-11-27 23:49 作者:xxadmin
阅读:次
[导读] php mssql 数据库连接类代码,代码如下: class DB_Sql{ var $Host = ; var $Database = ; var $User = ; var $Password = ; var $Link_ID =0; var $Query_ID =0; var $Record = array (); var $Row =0; var $Errno =0; var $Error = ; var $Auto_F...
php mssql 数据库连接类代码,代码如下:
-
class DB_Sql {
-
var $Host = "";
-
var $Database = "";
-
var $User = "";
-
var $Password = "";
-
var $Link_ID = 0;
-
var $Query_ID = 0;
-
var $Record = array();
-
var $Row = 0;
-
-
var $Errno = 0;
-
var $Error = "";
-
var $Auto_Free = 0; ## set this to 1 to automatically free results
-
-
-
-
function DB_Sql($query = "") {
-
$this->query($query);
-
}
-
function connect() {
-
if ( 0 == $this->Link_ID ) {
-
$this->Link_ID=mssql_connect($this->Host, $this->User, $this->Password);
-
if (!$this->Link_ID)
-
$this->halt("Link-ID == false, mssql_pconnect failed");
-
else
-
@mssql_select_db($this->Database, $this->Link_ID);
-
}
-
}
-
function free_result(){
-
mssql_free_result($this->Query_ID);
-
$this->Query_ID = 0;
-
}
-
-
function query($Query_String)
-
{
-
-
-
if ($Query_String == "")
-
-
-
-
-
return 0;
-
if (!$this->Link_ID)
-
$this->connect();
-
-
# printf("<br>Debug: query = %s<br> ", $Query_String);
-
-
$this->Query_ID = mssql_query($Query_String, $this->Link_ID);
-
$this->Row = 0;
-
if (!$this->Query_ID) {
-
$this->Errno = 1;
-
$this->Error = "General Error (The MSSQL interface cannot return detailed error messages).";
-
$this->halt("Invalid SQL: ".$Query_String);
-
}
-
return $this->Query_ID;
-
}
-
-
function next_record() {
-
-
|