本文实例讲述了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); }