注释的两个函数不知道怎么写。
另外,db_sqlserver_error.php文件很简单,就不写了。
有高手有更好的方案或者完善了其中注释的两个函数请在这里跟大家说一下。
注:该SQL Server类只为discuz开发而成,对于另外的网站可能需要做相应修改以适应其应用。本人不承担责任另行更改。
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class dbstuff {
var $querynum = 0;
var $lastInsertID = '';
function connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect = 0){
if($pconnect){
if(!@mssql_pconnect($dbhost, $dbuser, $dbpw)){
$this->halt('Can not connect to MSSql Server');
}
} else {
if(!@mssql_connect($dbhost, $dbuser, $dbpw)){
$this->halt('Can not connect to MSSql Server');
}
}
mssql_select_db($dbname);
}
function select_db($dbname) {
return mssql_select_db($dbname);
}
function fetch_array($query, $result_type = MSQL_ASSOC){
return mssql_fetch_array($query, $result_type);
}
function query($sql, $silence = 0){
$query = mssql_query($sql);
if(!$query && !$silence) {
$this->halt('MSSQL Query Error', $sql);
}
$this->querynum++;
$this->lastInsertID = mssql_result($query, 0, id);
return $query;
}
function unbuffered_query($sql, $silence = 0){
$funcname = @function_exists('mssql_unbuffered_query') ? 'mssql_unbuffered_query' : 'mssql_query';
$query = $funcname($sql);
if(!$query && !$silence) {
$this->halt('MSSQL Query Error', $sql);
}
$this->querynum++;
return $query;
}
function affected_rows(){
return mssql_rows_affected();
}
/*
function error(){
return mssql_error();
}
function errno(){
return something;
}
*/
function result($query, $row){
$query = @mssql_result($query, $row);
return $query;
}
function num_rows($query){
$query = mssql_num_rows($query);
return $query;
}
function num_fields($query) {
return mssql_num_fields($query);
}
function free_result($query) {
return mssql_free_result($query);
}
function insert_id() {
return $this->lastInsertID;
}
function fetch_row($query) {
$query = mssql_fetch_row($query);
return $query;
}
function close() {
return mssql_close();
}
function halt($message = '', $sql = '') {
require './include/db_sqlserver_error.php';
}
}
?>
(Conqueror)