The code is as follows:
class mysql {private $db;//datebase connect private $result;//MySQL result Stati C Private $mysql; MySQL Object private function __construct () {//the work before Create an object $this->db = mysql_connect (' Localho St ', ' root ', '); mysql_select_db (' Hello ', $this->db); public static function GetObject () {//if has a object,return that object,not the Create if (! Self:: $mysql instanceof Self) Self:: $mysql = new Self; Return self:: $mysql; Public Function Query ($sql) {$this->result = mysql_query ($sql, $this->db); return $this->result;} public func tion Fetch () {if (Isset ($this->result)) return Mysql_fetch_assoc ($this->result);} Public Function error () {RE Turn ' ERROR: '. mysql_error (); Public Function num ()//for SQL Select result {return mysql_num_rows ($this->result),} public function close () { return TRUE or False to return Mysql_close ($this->db); } }