获取mysql 版本

@param \PDO $link

@return string
486889
public function version($link = null)
    {
        is_null($link) && $link = $this->wlink;
        return $link->getAttribute(\PDO::ATTR_SERVER_VERSION);
    }
660188
public function linkBuilder($link)
    {
        if (is_array($link)) {
            list($route, $params) = $link;

            return $this->generateLink($route, $params);
        } else {
            return $this->generateLink($link, null);
        }
    }
944677
public function pathId($Path)
	{
		$Path = "root" . $Path;

		if ($Path [strlen ( $Path ) - 1] == "/")
			$Path = substr ( $Path, 0, strlen ( $Path ) - 1 );
		$Parts = explode ( "/", $Path );

		$Adapter = get_class(Jf::$Db);
		if ($Adapter == "mysqli" or ($Adapter == "PDO" and Jf::$Db->getAttribute(PDO::ATTR_DRIVER_NAME)=="mysql")) {
			$GroupConcat="GROUP_CONCAT(parent.Title ORDER BY parent.Lft SEPARATOR '/')";
		} elseif ($Adapter == "PDO" and Jf::$Db->getAttribute(PDO::ATTR_DRIVER_NAME)=="sqlite") {
			$GroupConcat="GROUP_CONCAT(parent.Title,'/')";
		} else {
			throw new \Exception ("Unknown Group_Concat on this type of database: {$Adapter}");
		}

		$res = Jf::sql ( "SELECT node.ID,{$GroupConcat} AS Path
				FROM {$this->tablePrefix()}{$this->type()} AS node,
				{$this->tablePrefix()}{$this->type()} AS parent
				WHERE node.Lft BETWEEN parent.Lft AND parent.Rght
				AND  node.Title=?
				GROUP BY node.ID
				HAVING Path = ?
				", $Parts [count ( $Parts ) - 1], $Path );

		if ($res)
			return $res [0] ['ID'];
		else
			return null;
			// TODO: make the below SQL work, so that 1024 limit is over

		$QueryBase = ("SELECT n0.ID  \nFROM {$this->tablePrefix()}{$this->type()} AS n0");
		$QueryCondition = "\nWHERE 	n0.Title=?";

		for($i = 1; $i < count ( $Parts ); ++ $i)
		{
			$j = $i - 1;
			$QueryBase .= "\nJOIN 		{$this->tablePrefix()}{$this->type()} AS n{$i} ON (n{$j}.Lft BETWEEN n{$i}.Lft+1 AND n{$i}.Rght)";
			$QueryCondition .= "\nAND 	n{$i}.Title=?";
			// Forcing middle elements
			$QueryBase .= "\nLEFT JOIN 	{$this->tablePrefix()}{$this->type()} AS nn{$i} ON (nn{$i}.Lft BETWEEN n{$i}.Lft+1 AND n{$j}.Lft-1)";
			$QueryCondition .= "\nAND 	nn{$i}.Lft IS NULL";
		}
		$Query = $QueryBase . $QueryCondition;
		$PartsRev = array_reverse ( $Parts );
		array_unshift ( $PartsRev, $Query );

		print_ ( $PartsRev );
		$res = call_user_func_array ( "Jf::sql", $PartsRev );

		if ($res)
			return $res [0] ['ID'];
		else
			return null;
	}
180057
public function queryFastHandle(string $sql, $bind = []): \PDOStatement
    {
        if (!$bind) {
            return $this->connectWrite()->query($sql, \PDO::FETCH_ASSOC);
        }

        $stmt = $this->connectWrite()->prepare($sql);
        $ret = $stmt->execute($bind);

        //通常是参数绑定问题
        if (!$ret) {
            trigger_error('PDO语句参数绑定错误:' . $stmt->errorCode(), E_USER_ERROR);
        }
        return $stmt;
    }
414094
public static function user_trailingslashit( $link ) {
		$link_parts = parse_url($link);

		if ( !$link_parts ) {
			return $link;
		}

		if ( isset($link_parts['path']) && $link_parts['path'] != '/' ) {
			$new_path = user_trailingslashit($link_parts['path']);

			if ( $new_path != $link_parts['path'] ) {
				$link = str_replace($link_parts['path'], $new_path, $link);
			}
		}
		return $link;
	}
1332497
protected function parseLinkHeader( $link ) {
		$parts = explode( ';', $link );
		$attrs = [
			'href' => trim( array_shift( $parts ), '<>' ),
		];
		foreach ( $parts as $part ) {
			if ( ! strpos( $part, '=' ) ) {
				continue;
			}
			list( $key, $value ) = explode( '=', $part, 2 );
			$key = trim( $key );
			$value = trim( $value, '" ' );
			$attrs[ $key ] = $value;
		}
		return $attrs;
	}
62091
public static function htmlID($link) {
        if(isset($link['id']) && is_string($link['id']) && !empty(trim($link['id']))) {
            return ' id="'.trim($link['id']).'"';
        }
        return false;
    }
1189305
protected function getDatabaseVersion(PDO $pdo)
    {
        try {
            $version = $pdo->getAttribute(PDO::ATTR_SERVER_VERSION);
        } catch (Exception $e) {
            $version = 0;
        }

        return $version;
    }
1001023
public function getDsn(): string
  {
    // pgsql:host=<hostname>;port=26257;dbname=bank;sslmode=disable

    # Build the DSN
    $_dsn = $this->getDriver().':' . 
            'host=' . $this->GetHost().';' . 
            'port=' . ($this->GetPort()!=0 ? $this->GetPort() . ':' : '26257' ) .
            'dbname=' . $this->GetSchema().';' .
            'sslmode=' . $this->getSSLMode();
            // 'charset='.$this->GetCharset();
    # Set it
    $this->setDsn($_dsn);
    # Results
    return $this->pdo_dsn;
  }
117314
function linkedPhp()
    {
        $matches = $this->getParsedLinkedPhp();
        $resolvedPhpVersion = $matches[3] ?: $matches[2];

        return $this->supportedPhpVersions()->first(   
            function ($version) use ($resolvedPhpVersion) {
                $resolvedVersionNormalized = preg_replace('/[^\d]/', '', $resolvedPhpVersion);
                $versionNormalized = preg_replace('/[^\d]/', '', $version);
                return $resolvedVersionNormalized === $versionNormalized;
        }, function () use ($resolvedPhpVersion) {
            throw new DomainException("Unable to determine linked PHP when parsing '$resolvedPhpVersion'");
        });
    }
933376
public function getInfo(string $key = null)
    {
        if ($this->info == null) {
            $resource = $this->linker->getLink()->getAgent()->getResource();
            $resourceType = $resource->getType();

            $serverVersion = $clientVersion = null;

            if ($resourceType == Resource::TYPE_MYSQL_LINK) {
                $object = $resource->getObject();
                foreach (get_class_vars(get_class($object)) as $var => $_) {
                    $this->info[$var] = $object->{$var};
                }
                $serverVersion = preg_replace('~\s*([^ ]+).*~', '\1', $object->server_info);
                $clientVersion = preg_replace('~(?:[a-z]+\s+)?([^ ]+).*~i', '\1', $object->client_info);
            } elseif ($resourceType == Resource::TYPE_PGSQL_LINK) {
                $this->info = pg_version($resource->getObject());
                $serverVersion = preg_replace('~\s*([^ ]+).*~', '\1', $this->info['server']);
                $clientVersion = preg_replace('~\s*([^ ]+).*~', '\1', $this->info['client']);
            }

            $this->info['serverVersion'] = $serverVersion;
            $this->info['clientVersion'] = $clientVersion;
        }

        return ($key == null) ? $this->info : $this->info[$key] ?? null;
    }
592939
public function setHref($menulink)
    {
        if ($menulink->url) {
            return $menulink->url;
        }
        if ($menulink->page) {
            return $menulink->page->uri();
        }

        return '/';
    }
1103911
protected function renderLinks($links)
    {
        $html = '';
        $navLink = wei()->navLink;

        /** @var NavLink $link */
        foreach ($links as $link) {
            $url = $link['subLinks'] ? 'javascript:;' : $this->linkTo->getUrl($link['linkTo']);
            $html .= '<a href="' . $url . '" class="js-header-nav-item hm-nav-link d-flex flex-center">';

            // 显示图标
            if ($navLink->displayIcon($link)) {
                if ($link['icon'] == 'image') {
                    $html .= '<img class="hm-nav-icon" src="' . $link['image'] . '">';
                } elseif ($link['icon'] == 'font') {
                    $html .= '<i class="hm-nav-icon ' . $link['font'] . '"></i>';
                } else {
                    $html .= '<i class="hm-nav-icon iconfont">' . $link['customFont'] . '</i>';
                }
            }

            // 显示文本
            if ($navLink->displayText($link)) {
                $html .= $link['name'];
            }

            $html .= '</a>';

            // 渲染子链接
            if ($link['subLinks']) {
                $html .= '<dl class="hm-nav-menu">';
                foreach ($link['subLinks'] as $subLink) {
                    $html .= '<dd><a href="' . $this->linkTo->getUrl($subLink['linkTo']) . '">';
                    $html .= $subLink['name'] . '</a></dd>';
                }
                $html .= '</dl>';
            }
        }

        return $html;
    }
647134
protected function jsonable(): string
    {
        $driverName = DB::connection()->getPdo()->getAttribute(PDO::ATTR_DRIVER_NAME);
        $dbVersion = DB::connection()->getPdo()->getAttribute(PDO::ATTR_SERVER_VERSION);
        $isOldVersion = version_compare($dbVersion, '5.7.8', 'lt');

        return $driverName === 'mysql' && $isOldVersion ? 'text' : 'json';
    }
291990
public function getDsn(): string
  {
/*
MYSQL:
  $connection = new \PDO('mysql:host=localhost;port=3306;dbname=test', $user, $pass,
    array(
      \PDO::ATTR_PERSISTENT => true
      \PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
      \PDO::ATTR_AUTOCOMMIT => FALSE,
      \PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"           // Set UTF8 as charset
    )
  );
*/
    # Build the DSN
    $_dsn = $this->getDriver().':'.
            'host='.$this->getHost().($this->getPort()!=0 ? ';port='.$this->getPort() : '' ).
            ';dbname='.$this->getSchema().
            ';charset='.$this->getCharset();

    # Set it
    $this->setDsn($_dsn);

    return $_dsn;
  }
1132170
public static function get($link, $args = null)
    {
        $base_url = self::base();

        $gen_link = $link;
        if ($args == null) {
            $gen_link = $base_url.$link;
        } elseif (!is_array($args)) {
            $gen_link = $base_url.'/'.str_replace('$1', $args, $link);
        } else {
            for ($i = 0; isset($args[$i]); ++$i) {
                $gen_link = str_replace('$'.($i + 1), $args[$i], $gen_link);
            }
            $gen_link = $base_url.$gen_link;
        }

        return $gen_link;
    }
517480
public function getResultUrl($linked = false)
    {
        $linkText = $this->cObj->typoLink_URL($this->getResultLinkConfiguration());
        $linkText = htmlspecialchars($linkText);
        if ($linked) {
            return $this->cObj->typoLink($linkText, $this->getResultLinkConfiguration());
        }
        return $linkText;
    }