一个MYSQL操作类

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

一个MYSQL操作类

  2021-03-17 我要评论
想了解一个MYSQL操作类的相关内容吗,在本文为您仔细讲解的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:一个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>";
}

}
?>

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们