class database {
var $dblink;
function connect($dbhost, $dbuser, $dbpw, $dbname = “”) {
$this->dblink = mysql_connect($dbhost, $dbuser, $dbpw);
mysql_query(“set names ‘utf8′”);
mysql_query(“set character_set_client=utf8”);
mysql_query(“set character_set_results=utf8”);
if($dbname) {
mysql_select_db($dbname, $this->dblink);
}
}
function query($sql) {
$result = mysql_query($sql, $this->dblink);
return $result;
}
function fetch_array($result) {
return mysql_fetch_array($result);
}
function insert_id() {
$id = mysql_insert_id();
return $id;
}
function getrow($sql) {
$result = mysql_query($sql, $this->dblink);
return mysql_fetch_assoc($result);
}
function getdetailrow($sql) {
$result = mysql_query($sql, $this->dblink);
return mysql_fetch_array($result);
}
//www.bKjia.c0m
function close() {
mysql_close($this->dblink);
}
}