public static function getInstance($connect = true) {
        if (!isset(self::$instances[static::class])) {
            self::$instances[static::class] = new static();
        }
        /** @var DB $instance */
        $instance = self::$instances[static::class];
        if ($connect) {
            $instance->connect();
        }
        return $instance;
    }