Connect(); } /*----------------------- 连接服务器,连接数据库 ------------------------*/ function Connect() { $this->Link_ID=mysql_connect($this->hostName,$this->rootName,$this->password) or die ("mysql connect failure!!!"); mysql_select_db($this->database, $this->Link_ID) or die ("database failure"); } /*----------------访问数据库,并返回处理数据后传回的值 ------------------*/ function query($string) { $result = mysql_query($string,$this->Link_ID); return $result; } function add($string) { $this->query($string); return $this->insert_id(); } function update($string) { return $this->query($string); } function delete($string) { return $this->query($string); } function get($string){ $res=$this->query($string); return mysql_num_rows($res); } //最近一次对数据库查询受影响的行数 function affected_rows(){ if($this->Query_ID != 0) return mysql_affected_rows($this->Link_ID); } function insert_id(){ return mysql_insert_id($this->Link_ID); } function num_fields(){ if($this->Query_ID != 0) return mysql_num_fields($this->Query_ID); } function fetch_row($result){ return @mysql_fetch_row($result); } function fetch_array($result){ return mysql_fetch_array($result); } function test(){ return "this is class db test"; } } ?>