<?php
namespace temmoku;
use \temmoku\connection;
class db
{

    private static $instance ;

    public static function connect(){
        if (!isset(self::$instance)) {
			$options= array(
               'host'     => C('dbhost'),
               'port'     => C('dbport'),
               'user'     => C('dbuser'),
               'password' => C('dbpassword'),
               'dbname'   => C('dbname'),
               'charset'  => C('charset'),
           );
            self::$instance = new connection($options);
        }
        return self::$instance;
    }

    /**
     * 清除连接实例
     * @access public
     * @return void
     */
    public static function clear(){
        self::$instance = [];
    }

    public static function __callStatic($method, $params){
        return call_user_func_array([self::connect(), $method], $params);
    }
}
