<?php
/*
 BMForum Datium! Bulletin Board Systems
 Version : Datium!
 
 This is a freeware, but don't change the copyright information.
 A SourceForge Project.
 Web Site: http://www.bmforum.com
 Copyright (C) Bluview Technology
*/
function bmbdb_connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect = 0, $mysqlchar = 0)
{
    if ($pconnect) {
        if (!@mysql_pconnect($dbhost, $dbuser, $dbpw)) {
            bmbdb_halt('Can not connect to MySQL server');
        } 
    } else {
        if (!@mysql_connect($dbhost, $dbuser, $dbpw)) {
            bmbdb_halt('Can not connect to MySQL server');
        } 
    } 
    $select_result = mysql_select_db($dbname);
    if ($mysqlchar == 1) mysql_query("SET NAMES 'utf8'");
    return $select_result;
} 

function bmbdb_select_db($dbname)
{
    $select_result = mysql_select_db($dbname);
    if ($mysqlchar == 1) mysql_query("SET NAMES 'utf8'");
    return $select_result;
} 

function bmbdb_fetch_array($query, $result_type = MYSQL_ASSOC)
{
    return mysql_fetch_array($query, $result_type);
} 

function bmbdb_query_fetch($sql, $silence = 0, $result_type = MYSQL_ASSOC)
{
    global $querynum;
	$query = bmbdb_query($sql, $silence);
    return bmbdb_fetch_array($query, $result_type);
} 

function bmbdb_query($sql, $silence = 0)
{
    global $querynum;
    $query = mysql_query($sql);
    if (!$query && !$silence) {
        bmbdb_halt('MySQL Query Error', $sql);
    } 
    $querynum++;
    return $query;
} 

function bmbdb_unbuffered_query($sql, $silence = 0)
{
    global $querynum;
    $func_unbuffered_query = @function_exists('mysql_unbuffered_query') ? 'mysql_unbuffered_query' : 'mysql_query';
    $query = $func_unbuffered_query($sql);
    if (!$query && !$silence) {
        bmbdb_halt('MySQL Query Error', $sql);
    } 
    $querynum++;
    return $query;
} 

function bmbdb_affected_rows()
{
    return mysql_affected_rows();
} 

function bmbdb_error()
{
    return mysql_error();
} 

function bmbdb_errno()
{
    return mysql_errno();
} 

function result($query, $row)
{
    $query = @mysql_result($query, $row);
    return $query;
} 

function bmbdb_num_rows($query)
{
    $query = mysql_num_rows($query);
    return $query;
} 

function bmbdb_num_fields($query)
{
    return mysql_num_fields($query);
} 

function bmbdb_free_result($query)
{
    return mysql_free_result($query);
} 

function bmbdb_insert_id()
{
    $id = mysql_insert_id();
    return $id;
} 

function bmbdb_fetch_row($query)
{
    $query = mysql_fetch_row($query);
    return $query;
} 

function bmbdb_close()
{
    mysql_close();
} 

function bmbdb_halt($message = '', $sql = '')
{
    require 'db_mysql_error.php';
} 

?>