<?php
if(!defined('AHBB_VOTE') || AHBB_VOTE !='zhu_'){
die('非法调用');
}
class mysql
{
private $conn;
function __construct($host,$user,$pwd,$database,$charset){
$this->mysql($host,$user,$pwd,$database,$charset);
}
function mysql($host,$user,$pwd,$database,$charset){
$this->conn=mysql_connect($host,$user,$pwd);
mysql_select_db($database);
mysql_query('set names '.$charset);
}
function query($sql){
$result=mysql_query($sql);
return $result;
}
function result($sql,$num) {
$result=mysql_query($sql);
if($result==false){
return false;
}
return @mysql_result($result,$num);
}
function getRow($sql){
$result=$this->query($sql);
if($result==false){
return false;
}
$row=mysql_fetch_assoc($result);
return $row;
}
function getAll($sql){
$result=$this->query($sql);
if($result==false){
return false;
}
while($row=mysql_fetch_assoc($result)){
$rows[]=$row;
}
return @$rows;
}
function fetch_assoc($result) {
return mysql_fetch_assoc($result);
}
function insert_id() {
return ($id=mysql_insert_id()) >=0 ? $id : $this->result($this->query('select last_insert_id()'),0);
}
function affected_rows() {
return mysql_affected_rows();
}
function close() {
mysql_close($this->conn);
}
}
?>
|