<?php /*MSSql的操作类*/ class mssql { public $link; public $querynum = 0; private $result; private static $server = ""; private static $user = "lhlgnews"; private static $password = "lhlgnews120925"; private static $dbname= "lhlgnews"; public function __construct(){ $this->link=odbc_connect("Driver={SQL Server};Server=".self::$server.";Database=".self::$dbname."",self::$user,self::$password,SQL_CUR_USE_ODBC); }//__construct // public function query($sql) { if($sql == ""){die("SQL ERROR:SQL IS NULL!");} $result = odbc_exec($this->link,$sql); if(!$result){ //调试用,sql语句出错时会自动打印出来 die("SQL:".$this->sql); }else{ $this->result = $result; }//if return $this->result; }//query public function db_num_rows(){ if($this->result==null){ die('SQL ERROR:Being empty, nothing!'); }else{ return odbc_fetch_row($this->result); } }//db_num_rows //getRow public function getRow($sql){ $result=odbc_exec($this->link,$sql); $i=0; while(odbc_fetch_row($result)) $i++; return ($i); } //insert and update public function doExe($sql){ $result=odbc_exec($this->link,$sql); return $result; } public function ReFree($result){ odbc_free_result($result); } public function __destruct(){ odbc_close_all(); odbc_close($this->link); } }//mssql
通用php连接mssql操作类
阅读:6310 输入:2015-12-26 15:40:10