<? class SQL {
var $Driver;
//实际操作的数据库驱动子类
var $connection;
//共用的数据库连接变量
function DriverRegister($d) {
if($d!="") { $include_path = ini_get("include_path");
$DriverFile = $include_path."/".$d.".php";
//驱动的存放路径必须在PHP.ini文件中设定的INCLUDE_PATH下
{
include($DriverFile); $this->Driver = new $d();
// 根据驱动名称生成相应的数据库驱动类
return true;
}
}
return false;
//注册驱动失败
}
function Connect($host,$user,$passwd,$database)
//连接数据库的函数
{ $this->Driver->host=$host;
$this->Driver->user=$user;
$this->Driver->passwd=$passwd;
$this->Driver->database=$database;
$this->connection = $this->Driver->Connect();
}
function Close()
//关闭数据库函数
{
$this->Driver->close($this->connection);
}
function Query($queryStr)
//数据库字符串查询函数 {
return $this->Driver->query($queryStr,$this->connection);
}
function getRows($res)
//查找行
{
return $this->Driver->getRows($res);
}
function getRowsNum($res)
//取得行号
{
return $this->Driver-> getRowsNum ($res);
}
}
? >