我是靠谱客的博主 忧虑大地,这篇文章主要介绍一个MYSQL操作类,现在分享给大家,希望可以做个参考。

复制代码 代码如下:

<?php
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 "<font color=\"#FF0000\">".$msg."</font>";
}

}
?>

最后

以上就是忧虑大地最近收集整理的关于一个MYSQL操作类的全部内容,更多相关一个MYSQL操作类内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(164)

评论列表共有 0 条评论

立即
投稿
返回
顶部