Returns driver-specific connection options

@param array $dsn DSN parameters

@return array Connection options
191289
protected function dsn_options($dsn)
    {
        $result = array();

        if ($this->db_pconn) {
            $result[PDO::ATTR_PERSISTENT] = true;
        }

        if (!empty($dsn['prefetch'])) {
            $result[PDO::ATTR_PREFETCH] = (int) $dsn['prefetch'];
        }

        if (!empty($dsn['timeout'])) {
            $result[PDO::ATTR_TIMEOUT] = (int) $dsn['timeout'];
        }

        return $result;
    }
127114
protected function parseAgnosticDsn(array $options)
    {
        if (isset($options['dsn']) && is_string($options['dsn'])) {
            $regex = '#^(?P<adapter>[^\\:]+)\\://(?:(?P<user>[^\\:@]+)(?:\\:(?P<pass>[^@]*))?@)?'
                   . '(?P<host>[^\\:@/]+)(?:\\:(?P<port>[1-9]\\d*))?/(?P<name>[^\?]+)(?:\?(?P<query>.*))?$#';
            if (preg_match($regex, trim($options['dsn']), $parsedOptions)) {
                $additionalOpts = [];
                if (isset($parsedOptions['query'])) {
                    parse_str($parsedOptions['query'], $additionalOpts);
                }
                $validOptions = ['adapter', 'user', 'pass', 'host', 'port', 'name'];
                $parsedOptions = array_filter(array_intersect_key($parsedOptions, array_flip($validOptions)));
                $options = array_merge($additionalOpts, $parsedOptions, $options);
                unset($options['dsn']);
            }
        }

        return $options;
    }
970916
function _connect($dsn)
    {
        if (is_string($dsn) || is_array($dsn)) {
        	if(!$this->db) {
	        	$this->db = ADONewConnection($dsn);
	    		if( $err = ADODB_Pear_error() ) {
	   	    		return PEAR::raiseError($err);
	    		}
        	}

        } else {
            return PEAR::raiseError('The given dsn was not valid in file ' . __FILE__ . ' at line ' . __LINE__,
                                    41,
                                    PEAR_ERROR_RETURN,
                                    null,
                                    null
                                    );
        }

        if(!$this->db) {
        	return PEAR::raiseError(ADODB_Pear_error());
        } else {
        	return true;
        }
    }
589367
protected function _dsn()
    {
        // baseline of DSN parts
        $dsn = $this->_config;

        // don't pass the username, password, charset, persistent and driver_options in the DSN
        unset($dsn['username']);
        unset($dsn['password']);
        unset($dsn['options']);
        unset($dsn['charset']);
        unset($dsn['persistent']);
        unset($dsn['driver_options']);

        // use all remaining parts in the DSN
        foreach ($dsn as $key => $val) {
            $dsn[$key] = "$key=$val";
        }

        return $this->_pdoType . ':' . implode(';', $dsn);
    }
568945
public function connect($dsn, $user = null, $passwd = null)
    {
        $parseUrl = parse_url($dsn);
        $pdoDsn = $parseUrl['path'];
        parent::connect($pdoDsn, $user, $passwd);
    }
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);
    }
1008176
public static function getDsn(array $options = [], $driver = null): string
    {
        if (isset($options['dsn'])) {
            return $options['dsn'];
        }

        self::$options = $options;

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

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

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

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

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

        self::$options = [];

        return $dsn;
    }
823946
public function setDriver($dsn, array $config = [], array $options = [])
    {
        $class = '\Micro\Db\Drivers\\'.ucfirst(substr($dsn, 0, strpos($dsn, ':'))).'Driver';

        if (!class_exists($class)) {
            throw new Exception('DB driver `'.$class.'` not supported');
        }

        unset($this->driver);

        $this->driver = new $class($dsn, $config, $options);
    }
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);
    }
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);
    }
1111919
public function setDsn(Dsn $dsn)
    {
        $this->dsn = $dsn;
        $keyspace = $dsn->getConfig()->getKeyspace();

        if (!$keyspace) {
            throw new Exception("SQLSTATE[3D000]: Invalid catalog name: 1046 No database selected");
        }

        $this->set(self::PARAM_KEYSPACE, new Parameter(self::PARAM_KEYSPACE, $keyspace));

        return $this;
    }
152427
public function getDriverName($conn = null)
    {
        $conn = $conn ?: $this->getConnectionName();

        return $this->config->get('queue.' . $conn . '.driver', 'sync');
    }
586433
public function connect($dsn, $username = NULL, $password = NULL)
	{
		$this->_pdo = new \PDO($dsn, $username, $password);
		$this->_pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
		return $this;
	}
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;
  }
1072807
protected function createPdoConnection($dsn, $username, $password, $options)
    {
        return new PDO($dsn, $username, $password, $options);
    }
452552
public function addConnection($name, $dsn, $username = null, $password = null, $options = [])
    {
        //default driver options
        static $defaultOptions = array(
            \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
            //PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
        );
        if (isset($options['prefix'])) {
            $prefix = $options['prefix'];
            unset($options['prefix']);
        } else {
            $prefix = '';
        }
        $this->configs[$name] = [
            'dsn' => $dsn,
            'username' => $username,
            'password' => $password,
            'prefix' => $prefix,
            'options' => $options + $defaultOptions,
        ];

        return $this;
    }
35480
public static function extractDsn($dsn)
    {
        // Parse DSN to array
        $dsn = str_replace(';', "\n", $dsn);

        $values = [];

        foreach (explode("\n", $dsn) as $value) {
            [$k, $v] = explode('=', trim($value));

            $values[$k] = $v;
        }

        return $values;
    }