>  기사  >  백엔드 개발  >  一个MYSQL操作类_PHP教程

一个MYSQL操作类_PHP教程

WBOY
WBOY원래의
2016-07-21 16:01:19941검색

复制代码 代码如下:

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."";
}

}
?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/316920.htmlTechArticle复制代码 代码如下: ?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(...
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.