classDB{
var$host_addr="localhost";
var$host_user="root";
var$host_psw="123";
var$db_name="test";
var$link_id;
var$query_id;
var$numRow;
functionDB(){
$this->link_id=@mysql_connect($this->host_addr,$this->host_user,$this->host_psw);
if($this->link_id){
@mysql_select_db($this->db_name,$this->link_id)or$this->halt("数据库连接失败!");
}else{
$this->halt("连接服务器失败!");
returnfalse;
}
return$this->link_id;
}
functionquery($sql){
$this->query_id=@mysql_query($sql,$this->link_id);
if($this->query_id){
return$this->query_id;
}else{
$this->halt("SQLError::");
returnfalse;
}
}
functionnumRow(){
return$this->numRow=@mysql_num_rows($this->query_id);
}
functionclose(){
return@mysql_close($this->link_id);
}
functionhalt($msg){
echo"
}
}
?>