您好,欢迎访问一九零五行业门户网

[php]mysql数据库操作DB类_MySQL

pconnect){
   $this->connection_id = mysql_pconnect($db_config[hostname], $db_config[username], $db_config[password]);
  }else{
   $this->connection_id = mysql_connect($db_config[hostname], $db_config[username], $db_config[password]);
  }
  if ( ! $this->connection_id ){
   $this->halt(can not connect mysql server);
  }
  if ( ! @mysql_select_db($db_config[database], $this->connection_id) ){
   $this->halt(can not connect mysql database);
  }
  if ($db_config[charset]) {
   @mysql_unbuffered_query(set names '.$db_config[charset].');
  }
  return true;
 }
 //发送sql 查询,并返回结果集
    function query($query_id, $query_type='mysql_query'){
        $this->query_id = $query_type($query_id, $this->connection_id);
  $this->queries[] = $query_id;
        if (! $this->query_id ) {
            $this->halt(查询失败:/n$query_id);
  }
  $this->query_count++;
  $this->query_log[] = $str;
        return $this->query_id;
    }
 //发送sql 查询,并不获取和缓存结果的行
 function query_unbuffered($sql=){
  return $this->query($sql, 'mysql_unbuffered_query');
 }
 //从结果集中取得一行作为关联数组
    function fetch_array($sql = ){
     if ($sql == ) $sql = $this->query_id;
        $this->record_row = @mysql_fetch_array($sql, mysql_assoc);
        return $this->record_row;
    }
 function shutdown_query($query_id = ){
  $this->shutdown_queries[] = $query_id;
    }
 //取得结果集中行的数目,仅对 insert,update 或者 delete
 function affected_rows() {
        return @mysql_affected_rows($this->connection_id);
    }
 //取得结果集中行的数目,仅对 select 语句有效
    function num_rows($query_id=) {
  if ($query_id == ) $query_id = $this->query_id;
        return @mysql_num_rows($query_id);
    }
 //返回上一个 mysql 操作中的错误信息的数字编码
 function get_errno(){
  $this->errno = @mysql_errno($this->connection_id);
  return $this->errno;
 }
 //取得上一步 insert 操作产生的 id
    function insert_id(){
        return @mysql_insert_id($this->connection_id);
    }
 //得到查询次数
    function query_count() {
        return $this->query_count;
    }
 //释放结果内存
    function free_result($query_id=){
     if ($query_id == ) $query_id = $this->query_id;
     @mysql_free_result($query_id);
    }
 //关闭 mysql 连接
    function close_db(){
     if ( $this->connection_id ) return @mysql_close( $this->connection_id );
    }
 //列出 mysql 数据库中的表
    function get_table_names(){
     global $db_config;
  $result = mysql_list_tables($db_config[database]);
  $num_tables = @mysql_numrows($result);
  for ($i = 0; $i    $tables[] = mysql_tablename($result, $i);
  }
  mysql_free_result($result);
  return $tables;
    }
 //从结果集中取得列信息并作为对象返回,取得所有字段
    function get_result_fields($query_id=){
     if ($query_id == ) $query_id = $this->query_id;
  while ($field = mysql_fetch_field($query_id)) {
            $fields[] = $field;
  }
  return $fields;
    }
 //错误提示
    function halt($the_error=){
  $message = $the_error.
/r/n;
  $message.= $this->get_errno() .
/r/n;
  $sql = insert into `db_error`(pagename, errstr, timer) values('.
[php]mysql数据库操作——db类 - 站长学院
未来的中国站长, 更加专注中国网络的发展广告服务 |最新更新 | 加入收藏 | 设为首页
首页 互联网软件 idc产品 站长交易 项目外包 商业信息 招聘 公司库 站长商城 资 讯下 载学 院工 具论 坛热门关键字:css布局配色参考dreamweaver8 apacheapacheiis6ajaxwml
首页 | home站长之家站长入门运营策划搜索优化网站盈利网页设计htmlcss/xhtmldhtmlwapdreamweaver设计原理平面动画photoshopfireworkflash网站开发asp.netphpjspmssqlaccessoraclemysql服务器fressbsdlinuxwindows
视频教程 常用手册 常用广告代码 js特效代码
站长学院 >> 网站开发技术教程 >> mysql教程  >> [php]mysql数据库操作——db类
[php]mysql数据库操作——db类 2008-4-13 6:12:00查看学习心得
{getproperty(content)}
其它类似信息

推荐信息