当前位置:Gxlcms > PHP教程 > NineMillionBicycles一个MYSQL操作类

NineMillionBicycles一个MYSQL操作类

时间:2021-07-01 10:21:17 帮助过:45人阅读

代码如下:


class DB{
var $host_addr = "localhost";
var $host_user = "root";
var $host_psw = "123";
var $db_name = "test";
var $link_id;
var $query_id;
var $numRow;
function DB(){
$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("连接服务器失败!");
return false;
}
return $this->link_id;
}
function query($sql){
$this->query_id = @mysql_query($sql,$this->link_id);
if($this->query_id){
return $this->query_id;
}else{
$this->halt("SQL Error::");
return false;
}
}
function numRow(){
return $this->numRow = @mysql_num_rows($this->query_id);
}
function close(){
return @mysql_close($this->link_id);
}
function halt($msg){
echo "".$msg."";
}
}
?>

以上就介绍了Nine Million Bicycles 一个MYSQL操作类,包括了Nine Million Bicycles方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

人气教程排行