一个MYSQL操作类_php教程-查字典教程网
一个MYSQL操作类
一个MYSQL操作类
发布时间:2016-12-29 来源:查字典编辑
摘要:复制代码代码如下:

复制代码 代码如下:

<?php

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"<fontcolor="#FF0000">".$msg."</font>";

}

}

?>

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新php教程学习
    热门php教程学习
    编程开发子分类