php mysql数据库操作类

2019-04-10 20:41:31王冬梅

    }
    //得到查询次数
    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 < $num_tables; $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."<br/>rn";
        $message.= $this->get_errno() . "<br/>rn";
        $sql = "INSERT INTO `db_error`(pagename, errstr, timer) VALUES('".$_SERVER["PHP_SELF"]."', '".addslashes($message)."', ".time().")";
相关文章 大家在看