经测试代码如下:
/**
* 封装了PHP操作MysqL的基本方法
*
* @param
* @arrange (512.笔记) jb51.cc
**/
class Database
{
var $db;
var $result;
var $lastQuery;
var $numQueries = 0;
var $error;
var $showErrors = true;
function Database($host,$user,$password,$dbname)
{
$this->db = MysqL_connect($host,$password) or die(MysqL_error());
MysqL_select_db($dbname,$this->db) or die(MysqL_error());
}
function query($sql)
{
$this->error = "";
$this->lastQuery = $sql;
if($this->showErrors)
$this->result = MysqL_query($sql,$this->db) or die(MysqL_error() . "<br/>--<br/>$sql");
else
$this->result = MysqL_query($sql,$this->db) or ($this->error = MysqL_error());
$this->numQueries++;
}
}
/*** 来自编程之家 jb51.cc(jb51.cc) ***/
原文链接:https://www.f2er.com/php/528897.html