<?php
/********************************************************************************
 * (c)1337 aheadware.com - All rights reserved
 ********************************************************************************/

/**
 * Class TB_Shared_Db_TeamData
 */
class TB_Shared_Db_TeamData {

    // Singleton pattern
    protected static $dbh = NULL;
    private function __construct() {}
    private function __clone() {}

    /**
     * Get single DB instance
     *
     * @return Francis_Db_MySql|null
     */
    public static function get() {
        if ( is_null( self::$dbh ) ) {
            self::$dbh = new Francis_Db_MySql( array(
                'host' => Francis_Utils_Config::get( 'db.tbteamdata.host' ),
                'name' => Francis_Utils_Config::get( 'db.tbteamdata.name' ),
                'user' => Francis_Utils_Config::get( 'db.tbteamdata.user' ),
                'pass' => Francis_Utils_Config::get( 'db.tbteamdata.pass' )
            ));
        }
        return self::$dbh;
    }

    /**
     * Deletes reference to DB connection and therefore closes it
     */
    public static function close()
    {
        self::$dbh = NULL;
    }
} 