mysql
query($sql,$database);
query_first($sql,$database);
fetch_array($sql,$database);
count_records($table,$index,$where,$database);)//为得到一个表记录的数目,$table为表名,$index为key,$where为条件,$dbbase为数据库,后两个可以不选
*/
class db_Mysql
{
var $usepconnect;
var $dbSever;
var $dbDatabase;
var $dbbase;
var $dbUser;
var $dbPwd;
var $dbLink;
var $query_id;// 执行query命令的指针
var $num_rows;// 返回的条目数
var $insert_id;// 传回最后一次使用 INSERT 指令的 ID
var $affected_rows;// 传回query命令所影响的列数目
// INSERT、UPDATE 或 DELETE 所影响的列 (row) 数目。
// delete 如果不带where,那么则返回0
function dbconnect($dbbase,$usepconnect)
{
//global $usepconnect;
if($usepconnect==1)
$this->dbLink=@mysql_pconnect($this->dbServer,$this->dbUser,$this->dbPwd);//long connect
else
$this->dbLink=@mysql_connect($this->dbServer,$this->dbUser,$this->dbPwd);//short connect
//$this->dbhalt($this->dbbase);
if(!$this->dbLink) $this->dbhalt("exsiting error when connecting!");
if($this->dbbase=="") $this->dbbase=$this->dbDatabase;
if(dbbase,$this->dbLink">!@mysql_select_db($this->dbbase,$this->dbLink))
$this->dbhalt("can't use this database,please check database!");
} // end func() connect database
//change database
function dbchange_db($dbbase){
$this->dbconnect($dbbase);
}
function dbquery($sql){
//if($dbbase!="") $this->dbchange_db($dbbase);
$this->query_id=mysql_query($sql);
//print($query_id);
if(!$this->query_id) $this->dbhalt("wrong sql sentence!".$sql);
return $this->query_id;
}
function dbquery_first($sql,$dbbase){
$query_id=dbquery($sql,$dbbase);
$returnarray=mysql_fetch_array($query_id);
$this->num_rows=mysql_num_rows($query_id);
$this->dbfree_result($query_id);
return $returnarray;
}
function dbhalt($errmsg){
$msg="
?>