本文實例講述了php的mssql數據庫連接類實例代碼,分享給大家供大家參考。具體實現代碼如下:復制代碼 代碼如下:html' target='_blank'>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
/* No empty queries, please, since PHP4 chokes on them. */ if ($Query_String == "") /* The empty query string is passed on from the constructor, * when calling the class without a query, e.g. in situations * like these: '$db = new DB_Sql_Subclass;' */ return 0; if (!$this- Link_ID) $this- connect();
function affected_rows() { // Not a supported function in PHP3/4. Chris Johnson, 16May2001. // return mssql_affected_rows($this- Query_ID); $rsRows = mssql_query("Select @@rowcount as rows", $this- Link_ID); if ($rsRows) { return mssql_result($rsRows, 0, "rows"); } }
function num_rows() { return mssql_num_rows($this- Query_ID); }
function num_fields() { return mssql_num_fields($this- Query_ID); } function nf() { return $this- num_rows(); }
function np() { print $this- num_rows(); }
function f($Field_Name) { return $this- Record[strtolower($Field_Name)]; }
function p($Field_Name) { print $this- f($Field_Name); }