<?php
//MysQL½Ó¿ÚÀà
class mydb{
	
	function connect($dbhost, $dbuser, $dbpw, $port, $dbname='',$dbcharset='') {
		if(!empty($port))
		{
			$dbhost=$dbhost.":".$port;
		}
		if(!@mysql_connect($dbhost, $dbuser, $dbpw)) {
			return false;
		}
		if($dbname) {
			if(!@($this->select_db($dbname)))
			{
				return false;
			}
		}
		if($dbcharset && $this->version() > '4.1') {
			$this->query("SET NAMES '".$dbcharset."'");
		}
		return true;
	}

	function select_db($dbname) {
		return mysql_select_db($dbname);
	}

	function fetch_array($query, $result_type = MYSQL_ASSOC) {
		return @mysql_fetch_array($query, $result_type);
	}

	function query($sql) {
		$query = @mysql_query($sql);
		$this->querynum++;
		return $query;
	}

	function affected_rows() {
		return mysql_affected_rows();
	}

	function result($query, $row) {
		return mysql_result($query, $row);
	}

	function num_rows($query) {
		return @mysql_num_rows($query);
	}

	function num_fields($query) {
		return mysql_num_fields($query);
	}

	function free_result($query) {
		return mysql_free_result($query);
	}

	function insert_id() {
		return mysql_insert_id();
	}

	function fetch_row($query) {
		return mysql_fetch_row($query);
	}

	function fetch_assoc($query){
		return @mysql_fetch_assoc($query);
	}
	
	function fetch_object(){
		return mysql_fetch_object($query);
	}
	
	function version() {
		return mysql_get_server_info();
	}

	function close() {
		return mysql_close();
	}

	function error() {
		return mysql_error();
	}
	
	function errno() {
		return mysql_errno();
	}
}