Converts a connection options array to the DSN

@param string[] $connectionOptions
773713
private function getConnectionOptionsDsn(array $connectionOptions) : string
    {
        $connectionOptionsDsn = '';

        foreach ($connectionOptions as $paramName => $paramValue) {
            $connectionOptionsDsn .= sprintf(';%s=%s', $paramName, $paramValue);
        }

        return $connectionOptionsDsn;
    }
689433
public function Connect ($dsn = FALSE, $user = FALSE, $pass = FALSE, $options = FALSE)
	{
		
		if (!$this->connected)
		{
			
			$this->_dsn		= $dsn?: $this->_dsn;
			$this->_user	= $user?: $this->_user;
			$this->_pass	= $pass?: $this->_pass;
			$this->_options	= $options?: $this->_options;
			
			parent::__construct ($this->_dsn, $this->_user, $this->_pass, $this->_options);
			
			$this->connected	= TRUE;
			
		}
		
	}
70748
protected function getOptions($dsn, $username, $password, $driverOptions)
    {
        $dsn = explode(':', $dsn);
        $driver = ucwords(array_shift($dsn));
        $dsn = explode(';', implode(':', $dsn));
        $configuredOptions = [];

        static::checkDriver($driver);

        foreach ($dsn as $kv) {
            $kv = explode('=', $kv);
            if (count($kv)) {
                $configuredOptions[$kv[0]] = $kv[1] ?? '';
            }
        }

        $authorization = [
            'user' => $username,
            'password' => $password,
        ];

        $configuredOptions = $driverOptions + $authorization + $configuredOptions;

        foreach (static::$keyMap as $pdoKey => $swpdoKey) {
            if (isset($configuredOptions[$pdoKey])) {
                $configuredOptions[$swpdoKey] = $configuredOptions[$pdoKey];
                unset($configuredOptions[$pdoKey]);
            }
        }

        return array_merge($configuredOptions, static::$options);
    }
931711
protected function prepareConstructOption($options) {
        if ($options instanceof DatabaseConfiguration) {
            $options = $options->toArray();
        }
        $opts    = array_merge([
            'encoding'       => 'UTF8',
            'dbname'         => '',
            'host'           => 'localhost',
            'port'           => 3306,
            'user'           => 'root',
            'password'       => 'root',
            'driver_options' => [
                \PDO::MYSQL_ATTR_COMPRESS => true
            ]
        ], $options);
        $charset = isset ($opts ['encoding']) && !empty ($opts ['encoding']) ? $opts ['encoding'] : 'UTF8';
        if ($charset == null) {
            $dsn = "mysql:dbname={$opts['dbname']};host={$opts['host']};port={$opts['port']}";
        } else {
            $dsn = "mysql:dbname={$opts['dbname']};host={$opts['host']};port={$opts['port']};charset={$charset}";
        }
        $this->charset = $charset;

        return [$dsn, $opts ['user'], $opts ['password'], $opts ['driver_options']];
    }
87303
public function setActiveConnections($connections)
    {
        if (!is_array($connections)) {
            $connections = explode(',', $connections);
        }

        // Sanitize and set connections
        $filtered = array_filter($connections, [$this, 'isValidConnection']);
        if (!$filtered) {
            throw new ConnectionException('Invalid connection(s): '.implode(', ', $connections));
        }

        $this->available = $this->getConnections()->map(function (ConnectionInterface $connection) use ($connections) {
            $connectionKey = $connection->getConnectionKey();
            $handle = $connectionKey->toHandle();

            $connection->setActive(in_array($handle, $connections, true) || in_array($connectionKey->name, $connections, true));
            $connection->setCurrent(false);

            return $connection;
        });
    }
1061578
protected function getConnectionByName(array $connectionNames)
    {
        $connections = [];
        foreach ($connectionNames as $connectionName) {
            $uniqueChannelId = $this->getUniqueChannelId($this->getConnectionMap()[$connectionName]);
            $connections[$uniqueChannelId] = $this->getConnectionMap()[$connectionName];
        }

        return $connections;
    }
313
public static function fromDSN($dsn)
    {
        $connParams = parse_url($dsn);
        $schemeInfo = explode('+', $connParams['scheme']);
        $modifier = null;
        $scheme = $schemeInfo[0];
        $dbName = isset($connParams['path']) ? substr($connParams['path'], 1) : null;

        if (isset($schemeInfo[1])) {
            $modifier = strtolower($schemeInfo[0]);
            $scheme = $schemeInfo[1];
        }

        if ($scheme != 'influxdb') {
            throw new ClientException($scheme . ' is not a valid scheme');
        }

        if (!in_array($modifier, ['udp'])) {
            throw new ClientException(sprintf("%s modifier specified in DSN is not supported", $modifier));
        }

        $driver = null;
        // set the UDP driver when the DSN specifies UDP
        if ($modifier == 'udp') {
            $driver = new UDP($connParams['host'], $connParams['port']);
        }

        $client = new self($driver);
        return ($dbName ? $client->selectDB($dbName) : $client);
    }
586335
protected function dbConnect(array $aOptions)
	{
		$aOptions = array_merge(SudoBible::DB_CREDS, $aOptions);
		try {
			$this->db = new mysqli(
				$aOptions['db_host'],
				$aOptions['db_user'],
				$aOptions['db_pass'],
				$aOptions['db_name'],
				$aOptions['db_port']
			);
		} catch (Exception $e) {
			// Clean up the error message
			throw new Exception(__METHOD__ . ': DB connection failed.');
		}
	}
672156
public static function createFromConnectionString($connectionString)
    {
        $tokenizedSettings = self::parseAndValidateKeys($connectionString);

        // Devstore case
        $matchedSpecs = self::matchedSpecification(
            $tokenizedSettings,
            self::allRequired(self::$_useDevelopmentStorageSetting),
            self::optional(self::$_developmentStorageProxyUriSetting)
        );
        if ($matchedSpecs) {
            $proxyUri = Utilities::tryGetValueInsensitive(
                Resources::DEVELOPMENT_STORAGE_PROXY_URI_NAME,
                $tokenizedSettings
            );

            return self::_getDevelopmentStorageAccount($proxyUri);
        }

        // Automatic case
        $matchedSpecs = self::matchedSpecification(
            $tokenizedSettings,
            self::allRequired(
                self::$_defaultEndpointsProtocolSetting,
                self::$_accountNameSetting,
                self::$_accountKeySetting
            ),
            self::optional(
                self::$_blobEndpointSetting,
                self::$_queueEndpointSetting,
                self::$_tableEndpointSetting
            )
        );
        if ($matchedSpecs) {
            return self::_createStorageServiceSettings(
                $tokenizedSettings,
                self::_getDefaultServiceEndpoint(
                    $tokenizedSettings,
                    Resources::BLOB_BASE_DNS_NAME
                ),
                self::_getDefaultServiceEndpoint(
                    $tokenizedSettings,
                    Resources::QUEUE_BASE_DNS_NAME
                ),
                self::_getDefaultServiceEndpoint(
                    $tokenizedSettings,
                    Resources::TABLE_BASE_DNS_NAME
                )
            );
        }

        // Explicit case
        $matchedSpecs = self::matchedSpecification(
            $tokenizedSettings,
            self::atLeastOne(
                self::$_blobEndpointSetting,
                self::$_queueEndpointSetting,
                self::$_tableEndpointSetting
            ),
            self::allRequired(
                self::$_accountNameSetting,
                self::$_accountKeySetting
            )
        );
        if ($matchedSpecs) {
            return self::_createStorageServiceSettings($tokenizedSettings);
        }

        self::noMatch($connectionString);
        return null;
    }
679549
public function beginTransaction($transactionOptions, array $options = [])
    {
        $res = $this->connection->beginTransaction([
            'projectId' => $this->projectId,
            'transactionOptions' => $transactionOptions
        ] + $options);

        return $res['transaction'];
    }
1088567
public function getConnectionOptions($con) {
    if (!isset($con)) $con = $this->getConnectionName();
    $conf = $this->project->getConfiguration();
  
    $connectionOptions = array(
      'dbname' => $conf->req(array('db',$con,'database')),
      'user' => $conf->req(array('db',$con,'user')),
      'password' => $conf->req(array('db',$con,'password')),
      'host' => $conf->req(array('db',$con,'host')),
      'driver' => 'pdo_mysql',
    );
    
    return $connectionOptions;
  }
781748
public function setConfiguration( models\Connection\Config $connectionConfig){
        $rest = $this->getService( self::API_CONNECTION_CONFIG);
        $rest->PUT( $connectionConfig);

        return $rest->getResult( models\Connection\Config::class);
    }
947056
public static function getDsn(array $options = [], $driver = null)
    {
        if (!empty($options['dsn'])) {
            return $options['dsn'];
        }

        self::$options = $options;

        if (!$driver) {
            $driver = $options['driver'] ?? null;
        }

        if (!$driver) {
            throw new \LogicException('The driver name is required.');
        }

        if (!\is_callable([static::class, $driver])) {
            throw new \RuntimeException('The ' . $driver . ' driver is not supported.');
        }

        list($dsn, $replace) = static::$driver();

        $dsn = strtr($dsn, $replace);

        self::$options = [];

        return $dsn;
    }
31164
protected function getConnectionOptions(): array
	{
		return $this->options +
		[
			PDO::ATTR_PERSISTENT         => $this->usePersistentConnection,
			PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION,
			PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ,
			PDO::ATTR_STRINGIFY_FETCHES  => false,
			PDO::ATTR_EMULATE_PREPARES   => false,
		];
	}
636672
public function normalizeOptions(array $options)
    {
        $options['useSsl'] = (bool) ($options['useSsl'] == 'SSL');
        $options['useStartTls'] = (bool) ($options['useStartTls'] == 'TLS');
        $options['accountCanonicalForm'] = $this->accountCanonicalFormMap[ $options['accountCanonicalForm'] ];

        return $options;
    }
517136
public function connectToCluster(array $config, array $clusterOptions, array $options)
    {
        $clusterSpecificOptions = Arr::pull($config, 'options', []);

        return new PredisClusterConnection(new Client(array_values($config), array_merge(
            $options, $clusterOptions, $clusterSpecificOptions
        )));
    }
429993
public function setCollectionOptions(array $collectionOptions)
    {
        if ($this->nested) {
            throw new LogicException(
                sprintf(
                    'Collection options cannot be set for nested document class "%s".',
                    $this->documentClass
                )
            );
        }

        $this->collectionOptions = $collectionOptions;

        return $this;
    }