src/DB/DBFactory.php
static function make($link, $params, array $config = array())
    {
        //如果params是一个匿名函数, 则调用匿名函数创建数据库连接
        if ($params instanceof Closure) {
            return call_user_func_array($params, $config);
        }

        //配置的数据表前缀
        $prefix = !empty($params['prefix']) ? $params['prefix'] : '';
        $options = isset($params['options']) ? $params['options'] : array();
        switch (strtolower($link)) {
            case 'mysql' :
                return new PDOSqlDriver(
                    MySQLConnecter::getInstance(self::getDsn($params, 'mysql'), $params['user'], $params['pass'], $options),
                    new MySQLAssembler($prefix)
                );

            case 'sqlite':
                return new PDOSqlDriver(SQLiteConnecter::getInstance($params['dsn'], null, null, $options), new SQLiteAssembler($prefix));

            case 'pgsql':
                return new PDOSqlDriver(
                    PgSqlConnecter::getInstance(self::getDsn($params, 'pgsql'), $params['user'], $params['pass'], $options),
                    new PgSQLAssembler($prefix)
                );

            case 'mongo':
                return new MongoDriver($params);

            case 'redis':
                return new RedisDriver($params);

            case 'memcache':
                return new MemcacheDriver($params);

            case 'couch':
                return new CouchDriver($params);

            default:
                throw new CoreException('不支持的数据库扩展!');
        }
    }
static function make($link, $params, array $config = array())
    {
        //如果params是一个匿名函数, 则调用匿名函数创建数据库连接
        if ($params instanceof Closure) {
            return call_user_func_array($params, $config);
        }

        //配置的数据表前缀
        $prefix = !empty($params['prefix']) ? $params['prefix'] : '';
        $options = isset($params['options']) ? $params['options'] : array();
        switch (strtolower($link)) {
            case 'mysql' :
                return new PDOSqlDriver(
                    MySQLConnecter::getInstance(self::getDsn($params, 'mysql'), $params['user'], $params['pass'], $options),
                    new MySQLAssembler($prefix)
                );

            case 'sqlite':
                return new PDOSqlDriver(SQLiteConnecter::getInstance($params['dsn'], null, null, $options), new SQLiteAssembler($prefix));

            case 'pgsql':
                return new PDOSqlDriver(
                    PgSqlConnecter::getInstance(self::getDsn($params, 'pgsql'), $params['user'], $params['pass'], $options),
                    new PgSQLAssembler($prefix)
                );

            case 'mongo':
                return new MongoDriver($params);

            case 'redis':
                return new RedisDriver($params);

            case 'memcache':
                return new MemcacheDriver($params);

            case 'couch':
                return new CouchDriver($params);

            default:
                throw new CoreException('不支持的数据库扩展!');
        }
    }
为module中的link生成对象的实例,在配置文件中支持匿名函数

@param string $link
@param array|Closure $params
@param array $config
@return RedisDriver|CouchDriver|MongoDriver|PDOSqlDriver|mixed
@throws CoreException