Get DSN - Return the default formatted DSN

This method needs to be overridden in DB Driver specific files

@return string       [description]
166197
public function getDsn(): string
  {
    # Build the DSN
    $_dsn = $this->driver.':host='.$this->host.';port='.$this->port.';dbname='.$this->schema.';charset='.$this->charset;
    # Set it
    $this->setDsn($_dsn);

    return $this->pdo_dsn;
  }
842574
public static function Get($dsn = null, $use_as_default = false) {
		if ($dsn !== null AND $use_as_default) {
			self::$default_dsn = $dsn;
		} elseif ($dsn === null AND self::$default_dsn !== null) {
			$dsn = self::$default_dsn;
		}

		/**
		 * A mysqli connection can only be accessed by the PID that has created it
		 * Create a new Mysqli object after forking
		 */
		if (isset(self::$pids[$dsn]) and self::$pids[$dsn] != getmypid()) {
			unset(self::$proxy[$dsn]);
			unset(self::$pids[$dsn]);
		}

		if (!isset(self::$proxy[$dsn]) OR self::$proxy[$dsn] == false) {
			self::$proxy[$dsn] = new Proxy($dsn);
			self::$pids[$dsn] = getmypid();
		}
		return self::$proxy[$dsn];
	}
718239
public function getAdapter()
    {
        $adapter = $this->dsn->adapter;

        if ($adapter !== null) {
            return $adapter;
        }

        $scheme = $this->dsn->scheme;

        if (isset(static::$adapterMap[$scheme])) {
            return static::$adapterMap[$scheme];
        }

        return null;
    }
985696
public function getDsn()
    {
        if ($this->checkParam()) {
            $sDsn = 'odbc:Driver={' . $this->getDriver() . '};';
            if (!empty($this->getUser())) {
                $sDsn .= 'Uid=' . $this->getUser() . ';';
            } else {
                $sDsn .= 'Uid=Admin;';
            }
            $sDsn .= 'Pwd=' . $this->getPassword() . ';Dbq=' . $this->getDatabase() . ';';
            if (!empty($this->getSystemDatabase())) {
                $sDsn .= 'SystemDB=' . $this->getSystemDatabase() . ';';
            }
            return $sDsn;
        } else {
            return false;
        }
    }
5253
public function getDsn()
    {
        if (!$this->config) {
            return '';
        }
        $dsn = array();
        $dbName = null;

        if ($this->config->getName()) {
            $dbName = $this->config->getName();
        }

        if ($this->config->getHost()) {
            if ($this->config->getPort()) {
                $dsn[] = sprintf('dbname=//%s:%s/%s',
                    $this->config->getHost(),
                    $this->config->getPort(),
                    $dbName
                );
            } else {
                $dsn[] = sprintf('dbname=//%s/%s',
                    $this->config->getHost(),
                    $dbName
                );
            }
        } else {
            $dsn[] = 'dbname='.$dbName;
        }

        if ($this->config->getChar()) {
            $dsn[] = 'charset='.$this->config->getChar();
        }

        return $this->getPrefix().implode(';', $dsn);
    }
1337263
public function getConnection()
    {
        // Initiate connection if not exist
        if ($this->connection === null) {
            $this->connection = DriverManager::getConnection($this->dsn);
        }

        return $this->connection;
    }
56170
public function getDsn()
    {
        if ($this->rawConfig['dsn']) {
            return $this->rawConfig['dsn'];
        }

        if (isset($this->connectionStrings[$this->getType()])) {
            return $this->connectionStrings[$this->getType()]->getDsn();
        }
    }
1373253
public function getDatasource()
    {
        $adapter = $this->getAdapter();

        if ($adapter) {
            return $adapter;
        }

        $engine = $this->dsn->engine;

        return 'Database/' . ucfirst($engine);
    }
375293
private function DBConnectComand()
    {
        /*
        * Check Database Connection
        */
        switch ($this->DB_TYPE){
        case 'sqlite':
            $dsn = 'sqlite:'.$this->DB_DATABASE;
            $this->validateSqliteFile($this->DB_DATABASE);
            break;

        case 'pgsql':
            $dsn ='pgsql:host='.$this->DB_HOST.';dbname='.$this->DB_DATABASE.';port='.$this->DB_PORT;
            break;

        case 'sqlsrv':
            $availableDrivers = \PDO::getAvailableDrivers();
            if (in_array('dblib', $availableDrivers)) {
                $dsn = 'dblib:host='.$this->DB_HOST.$this->DB_PORT.';dbname='.$this->DB_DATABASE;
            }
            else {
                $dsn = 'sqlsrv:Server='.$this->DB_HOST.$this->DB_PORT.';Database='.$this->DB_DATABASE;
            }
            break;

        default:
            $dsn = 'mysql:host='.$this->DB_HOST.';dbname='.$this->DB_DATABASE.';port='.$this->DB_PORT;
            break;
        }

        return $dsn;
    }
577428
protected function getPDO()
    {
        if (null === $this->pdo) {
            $this->pdo = new \PDO($this->dsn, $this->user, $this->password, $this->options);
        }
        return $this->pdo;
    }
1067429
protected function dsn_string($dsn)
    {
        $params = array();
        $result = 'mysql:';

        if ($dsn['database']) {
            $params[] = 'dbname=' . $dsn['database'];
        }

        if ($dsn['hostspec']) {
            $params[] = 'host=' . $dsn['hostspec'];
        }

        if ($dsn['port']) {
            $params[] = 'port=' . $dsn['port'];
        }

        if ($dsn['socket']) {
            $params[] = 'unix_socket=' . $dsn['socket'];
        }

        $params[] = 'charset=utf8';

        if (!empty($params)) {
            $result .= implode(';', $params);
        }

        return $result;
    }
204528
public static function getDefault()
    {
        if (self::existsDefault()) {
            $defaultConnectionName = self::$defaultConnectionName;
            return self::$connectionList[$defaultConnectionName];
        } else {
            throw new Exception('Datasource "' . $defaultConnectionName . '" isn\'t defined in DatasourceCollection');
            return false;
        }
    }
994830
public function getDsn()
    {
        if (!$this->config) {
            return '';
        }
        $dsn = array();

        if ($this->config->getHost()) {
            $dsn[] = 'host='.$this->config->getHost();
        }

        if ($this->config->getPort()) {
            $dsn[] = 'port='.$this->config->getPort();
        }

        if ($this->config->getName()) {
            $dsn[] = 'dbname='.$this->config->getName();
        }

        if ($this->config->getUser()) {
            $dsn[] = 'user='.$this->config->getUser();
        }

        if ($this->config->getPass()) {
            $dsn[] = 'password='.$this->config->getPass();
        }

        return $this->getPrefix().implode(';', $dsn);
    }
438375
public static function getConnection($dsn)
    {
        if (!is_array($dsn)) {
            $dsn = self::parseDsn($dsn);
        }
        if (!isset($dsn['adapter'])) {
            throw new Exception("database adapter is missing for " . json_encode($dsn));
        }
        $class = 'Phalcon\Db\Adapter\Pdo\\' . ucfirst($dsn['adapter']);
        $conn = new $class($dsn);
        return Mixin::create($conn, new self);
    }
219531
protected function getDefaultPort()
    {
	    $driver = $this->mysql->driver;
	    $key    = $driver . '.default_port';
	    $port   = ini_get($key);

	    if ($port) {
	    	return $port;
	    }

	    return ini_get('mysqli.default_port');
    }
663510
private function getDSN($server, $type, $database)
    {
        if ($this->isPDO($type)) {
            $dsn = substr(strtolower($type), 4) . ':';
            if (strstr($server, ':')) {
                list($host, $port) = explode(':', $server, 2);
                $dsn .= 'host=' . $host . ';port=' . $port; 
            } else {
                $dsn .= 'host=' . $server;
            }
            if ($database) {
                $dsn .= ';dbname=' . $database;
            }

            return $dsn;
        } else {
            return $server;
        }
    }
655163
function getDN($format = self::DN_ARRAY, $dn = null)
    {
        if (!isset($dn)) {
            $dn = isset($this->currentCert['tbsCertList']) ? $this->currentCert['tbsCertList']['issuer'] : $this->dn;
        }

        switch ((int) $format) {
            case self::DN_ARRAY:
                return $dn;
            case self::DN_ASN1:
                $asn1 = new ASN1();
                $asn1->loadOIDs($this->oids);
                $filters = array();
                $filters['rdnSequence']['value'] = array('type' => ASN1::TYPE_UTF8_STRING);
                $asn1->loadFilters($filters);
                $this->_mapOutDNs($dn, 'rdnSequence', $asn1);
                return $asn1->encodeDER($dn, $this->Name);
            case self::DN_CANON:
                //  No SEQUENCE around RDNs and all string values normalized as
                // trimmed lowercase UTF-8 with all spacing as one blank.
                // constructed RDNs will not be canonicalized
                $asn1 = new ASN1();
                $asn1->loadOIDs($this->oids);
                $filters = array();
                $filters['value'] = array('type' => ASN1::TYPE_UTF8_STRING);
                $asn1->loadFilters($filters);
                $result = '';
                $this->_mapOutDNs($dn, 'rdnSequence', $asn1);
                foreach ($dn['rdnSequence'] as $rdn) {
                    foreach ($rdn as $i => $attr) {
                        $attr = &$rdn[$i];
                        if (is_array($attr['value'])) {
                            foreach ($attr['value'] as $type => $v) {
                                $type = array_search($type, $asn1->ANYmap, true);
                                if ($type !== false && isset($asn1->stringTypeSize[$type])) {
                                    $v = $asn1->convert($v, $type);
                                    if ($v !== false) {
                                        $v = preg_replace('/\s+/', ' ', $v);
                                        $attr['value'] = strtolower(trim($v));
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    $result .= $asn1->encodeDER($rdn, $this->RelativeDistinguishedName);
                }
                return $result;
            case self::DN_HASH:
                $dn = $this->getDN(self::DN_CANON, $dn);
                $hash = new Hash('sha1');
                $hash = $hash->hash($dn);
                extract(unpack('Vhash', $hash));
                return strtolower(bin2hex(pack('N', $hash)));
        }

        // Default is to return a string.
        $start = true;
        $output = '';

        $result = array();
        $asn1 = new ASN1();
        $asn1->loadOIDs($this->oids);
        $filters = array();
        $filters['rdnSequence']['value'] = array('type' => ASN1::TYPE_UTF8_STRING);
        $asn1->loadFilters($filters);
        $this->_mapOutDNs($dn, 'rdnSequence', $asn1);

        foreach ($dn['rdnSequence'] as $field) {
            $prop = $field[0]['type'];
            $value = $field[0]['value'];

            $delim = ', ';
            switch ($prop) {
                case 'id-at-countryName':
                    $desc = 'C';
                    break;
                case 'id-at-stateOrProvinceName':
                    $desc = 'ST';
                    break;
                case 'id-at-organizationName':
                    $desc = 'O';
                    break;
                case 'id-at-organizationalUnitName':
                    $desc = 'OU';
                    break;
                case 'id-at-commonName':
                    $desc = 'CN';
                    break;
                case 'id-at-localityName':
                    $desc = 'L';
                    break;
                case 'id-at-surname':
                    $desc = 'SN';
                    break;
                case 'id-at-uniqueIdentifier':
                    $delim = '/';
                    $desc = 'x500UniqueIdentifier';
                    break;
                case 'id-at-postalAddress':
                    $delim = '/';
                    $desc = 'postalAddress';
                    break;
                default:
                    $delim = '/';
                    $desc = preg_replace('#.+-([^-]+)$#', '$1', $prop);
            }

            if (!$start) {
                $output.= $delim;
            }
            if (is_array($value)) {
                foreach ($value as $type => $v) {
                    $type = array_search($type, $asn1->ANYmap, true);
                    if ($type !== false && isset($asn1->stringTypeSize[$type])) {
                        $v = $asn1->convert($v, $type);
                        if ($v !== false) {
                            $value = $v;
                            break;
                        }
                    }
                }
                if (is_array($value)) {
                    $value = array_pop($value); // Always strip data type.
                }
            } elseif (is_object($value) && $value instanceof Element) {
                $callback = function ($x) {
                    return "\x" . bin2hex($x[0]);
                };
                $value = strtoupper(preg_replace_callback('#[^\x20-\x7E]#', $callback, $value->element));
            }
            $output.= $desc . '=' . $value;
            $result[$desc] = isset($result[$desc]) ?
                array_merge((array) $dn[$prop], array($value)) :
                $value;
            $start = false;
        }

        return $format == self::DN_OPENSSL ? $result : $output;
    }