很多朋友问我如何用php程序来连接sql server数据库的通用类,其实这个并不是很难的,关键是一点点仔细,一点点耐心,用激情去理解 <? class db { var $host = "192.168.0.199"; // hostname of our mysql server var $database = "test"; // logical database name on that server var $user = "user"; // database user var $password = "password"; // database user's password
var $link_id = 0; // result of mssql_connect() var $query_id = 0; // result of most recent mssql_query() var $row = 0; // current row number var $errno = 0; // error state of query var $error = "";
/************************************** *连接数据库,并且选择默认的数据库 **************************************/ function connect() { if ( 0 == $this->link_id ) { $this->link_id=mssql_connect($this->host,$this->user,$this->password) or die("couldn't connect to sql server on