[b]database.class.php[/b]
<?php
class database {
    
    var $prefix;
    var $tijd;
    var $sqltijd;
    var $connection;
    var $querys = 0;
    var $fetchs = 0;
    var $numrows = 0;
    var $customError = false;
    var $customErrorMSG = "Er is een database fout.  Gelieve later nog eens te proberen!";

    function database($host = "", $gebruiker = "", $wachtwoord = "", $database = "", $prefix = "") {
        $this->connection = mysql_connect($host, $gebruiker, $wachtwoord)or die($this->__error(mysql_error()));
        $this->prefix = $prefix;
        mysql_select_db($database, $this->connection)or die($this->__error(mysql_error()));
    }
    
    function reconnect($host, $user, $pass) {
        $this->connection = mysql_connect($host, $user, $pass) OR die($this->__error(mysql_error()));
        if(!$this->connection)
            die($this->__error(mysql_error()));
    }
    
    function reselect_db($db){
        mysql_select_db($db, $this->currentDB) OR die($this->__error(mysql_error()));
    }
    
    function set_prefix ($prefix) {
        $this->prefix = $prefix;
    }

    function unset_prefix () {
        $this->prefix = NULL;
    }
    
    function set_customError (){
        $this->customError = true; // set true of false
    }
    
    function unset_customError(){
        $this->customError = false;
    }
    
    function set_customErrorMSG ($msg=""){
        $this->customErrorMSG = $msg;
    }
    
    function query($query) {
        $microtime_start = $this->__getmicrotime();
        $query = preg_replace("/\[prefix\]/si", $this->prefix, $query);
        $return = mysql_query($query)or die($this->__error(mysql_error()));
        $microtime = $this->__getmicrotime() - $microtime_start;
        $this->tijd += $microtime;
        $this->sqltijd += $microtime;
        $this->querys ++;
        return $return;
    }

    function num_rows($query) {
        $microtime_start = $this->__getmicrotime();
        $return = mysql_num_rows($query);
        $this->sqltijd += $this->__getmicrotime() - $microtime_start;
        $this->numrows++;
        return $return;
    }

    function fetch_assoc($query) {
        $microtime_start = $this->__getmicrotime();
        $return = mysql_fetch_assoc($query);
        $this->sqltijd += $this->__getmicrotime() - $microtime_start;
        $this->fetchs++;
        return $return;
    }
    
    function fetch_object($query) {
        $microtime_start = $this->__getmicrotime();
        $return = mysql_fetch_object($query);
        $this->sqltijd += $this->__getmicrotime() - $microtime_start;    
        $this->fetchs++;
        return $return;
    }
    
    function fetch_array($query) {
        $microtime_start = $this->__getmicrotime();
        $return = mysql_fetch_array($query);
        $this->sqltijd += $this->__getmicrotime() - $microtime_start;
        $this->fetchs++;
        return $return;
    }

    function __getmicrotime() {
        $microtime = explode(" ", microtime());
        return $microtime[0] + $microtime[1];
    }

    function results ($release="") {
        switch ($release) {
            case "querys": $toRelease = $this->querys; break;
            case "fetchs": $toRelease = $this->fetchs; break;
            case "numrows": $toRelease = $this->numrows; break;
            case "time": $toRelease = $this->tijd; break;
            case "sqltijd": $toRelease = $this->sqltijd; break;
            default: $toRelease = NULL; break;
        }
        
        return $toRelease;
    }

    function reset_counters () {
        $this->sqltijd = NULL;
        $this->tijd = NULL;
        $this->querys = NULL;
        $this->sqltijd = NULL;
        $this->fetchs = NULL;
        $this->numrows = NULL;
    }
    
    function __error ($error="") {
        if($customError)
            $error = $customErrorMSG;
        
        return $error
    }
    
    function close () {
        @mysql_close($this->connection);
    }
}
?>

[b]toevoegen aan config.php:[/b]
<?php
require ("database.class.php");
$db = new database ("host", "user", "wachtwoord", "database", "prefix");
// de dingen hierboven moet je vervangen door je eigen gegevens.  De velden zijn NIET verplicht!
?>