core/Mysql.php
public static function instance()
    {
        if (self::$instance == null) {
            $host = Config::get('db.db_host', '127.0.0.1');
            $port = Config::get('db.db_port', 3306);
            $name = Config::get('db.db_name', '');
            $user = Config::get('db.db_user', '');
            $pass = Config::get('db.db_pwd', '');
            $prefix = Config::get('db.db_prefix', 'sl_');
            $charset = Config::get('db.db_charset', 'utf8');
            try {
                self::$instance = new Mysql($host, $port, $name, $user, $pass, $prefix, $charset);
            } catch (\PDOException $e) {
                self::$instance = null;
                throw new MysqlException($e->getMessage(), '', $e->getCode(), $e);
            } catch (\Exception $e) {
                self::$instance = null;
                throw new MysqlException($e->getMessage(), '', $e->getCode(), $e);
            }
        }
        return self::$instance;
    }
public static function instance()
    {
        if (self::$instance == null) {
            $host = Config::get('db.db_host', '127.0.0.1');
            $port = Config::get('db.db_port', 3306);
            $name = Config::get('db.db_name', '');
            $user = Config::get('db.db_user', '');
            $pass = Config::get('db.db_pwd', '');
            $prefix = Config::get('db.db_prefix', 'sl_');
            $charset = Config::get('db.db_charset', 'utf8');
            try {
                self::$instance = new Mysql($host, $port, $name, $user, $pass, $prefix, $charset);
            } catch (\PDOException $e) {
                self::$instance = null;
                throw new MysqlException($e->getMessage(), '', $e->getCode(), $e);
            } catch (\Exception $e) {
                self::$instance = null;
                throw new MysqlException($e->getMessage(), '', $e->getCode(), $e);
            }
        }
        return self::$instance;
    }
获取一个单例
@return Mysql|null
@throws MysqlException