Get a connection

@access public
@param mixed $config
@return object
485980
public static function get($config = null) {
		if (!isset($config['driver'])) {
			throw new ConnectionException("Unknown driver");
		}
		if (!isset($config['host']) || !isset($config['port'])) {
			throw new ConnectionException("Host and Port is required");
		}
		$type = $config['driver'];
		$hash = md5($type . ':' . $config['host'] . ':' . $config['port']);
		if (!isset(self::$created_driver[$hash])) {
			if (isset(self::$driver[$type])) {
				$className = self::$driver[$type];
			} else {
				$className = __NAMESPACE__ . '\\Driver\\' . ucfirst($type);
			}
			self::$created_driver[$hash] = new $className($config);
		}
		return self::$created_driver[$hash];
	}
624798
protected function getDsn(array $config)
    {
        // First we will create the basic DSN setup as well as the port if it is in
        // in the configuration options. This will give us the basic DSN we will
        // need to establish the PDO connections and return them back for use.
        extract($config, EXTR_SKIP);

        $host = isset($host) ? "host={$host};" : '';

        $dsn = "pgsql:{$host}dbname={$database}";

        // If a port was specified, we will add it to this Postgres DSN connections
        // format. Once we have done that we are ready to return this connection
        // string back out for usage, as this has been fully constructed here.
        if (isset($config['port'])) {
            $dsn .= ";port={$port}";
        }

        return $this->addSslOptions($dsn, $config);
    }
152380
public function connect(array $config)
    {
        $queue = new RedisQueue(
            $this->redis, $config['queue'], array_get($config, 'connection', $this->connection)
        );

        $queue->setExpire(array_get($config, 'expire', 60));

        return $queue;
    }
550899
protected function getClient(array $config)
    {
        $name = array_get($config, 'adapter');
        $config = $this->manager->getConnectionConfig($name);

        return $this->manager->getFactory()->createAdapter($config);
    }
999706
public function getRequest($config = array())
    {
        $config['consumer'] = $this->getConsumer();
        $config['token'] = $this->getToken();
        $config['version'] = $this->getVersion();

        return new ComConnectOauthRequest(new AnConfig($config));
    }
965729
protected function getClient(array $config): Client
    {
        $client = Client::create($config['url']);

        $client->authenticate(
            $config['token'],
            array_get($config, 'method', Client::AUTH_URL_TOKEN),
            array_get($config, 'sudo', null)
        );

        return $client;
    }
83517
protected function getHostDsn(array $config)
    {
        if (!isset($config['host'])) {
            throw new DbException("Db connection host can not be empty.");
        }

        if (!isset($config['database'])) {
            throw new DbException("Db connection database can not be empty.");
        }

        $charset    = "";
        if (null != $this->config['charset']) {
            $charset = ";charset={$this->config['charset']}";
        }

        if (isset($config['port'])) {
            return "mysql:host={$config['host']};port={$config['port']};dbname={$config['database']}" . $charset;
        }

        return "mysql:host={$config['host']};dbname={$config['database']}" . $charset;
    }
143080
public function connect(array $config)
	{
		return new DatabaseQueue(
			$this->connections->connection(Arr::get($config, 'connection')),
			$config['table'],
			$config['queue'],
			Arr::get($config, 'expire', 60)
		);
	}
865711
public function connect(array $config)
    {
        $auth = $this->getAuth($config);
        $client = $this->getClient($auth);

        return $this->getAdapter($client);
    }
1238335
public function getConnection($connKey)
    {
        if (isset(self::$connectionObject[$connKey]) && self::$connectionObject[$connKey] instanceof PDO) {
            return self::$connectionObject[$connKey];
        }

        $config = [];
        $config = Configure::getDatabaseConfiguration();

        foreach ($config as $key => $value) {
            if (trim($value['database']) == trim($connKey)) {
                return self::$connectionObject[$connKey] = $this->setConnection($value);
            }
        }
    }
1306412
protected function getDsn(array $config)
    {
        return $this->configHasSocket($config) ? $this->getSocketDsn($config) : $this->getHostDsn($config);
    }
593700
public static function connect(ConnectionParameters $config){

		//Not static
		$con = new self();
		
		switch(\strtolower(\trim($config->getDriver()))){
			
			case 'sqlite':
				$con->Connection = new \PDO(
						\sprintf('sqlite:%s', $config->getHost()),
						$config->getUsername(),
						$config->getPassword(),
						$config->getOptions());
				break;
			
			default:
				$con->Connection = new \PDO(\sprintf(
						'%s:host=%s;charset=%s;dbname=%s',
						$config->getDriver() ? $config->getDriver() : '',
						$config->getHost() ? $config->getHost() : '',
						$config->getCharset() ? $config->getCharset() : '',
						$config->getDatabaseName() ? $config->getDatabaseName() : ''
					),
					$config->getUsername(),
					$config->getPassword(),
					$config->getOptions());
				break;
			
		}
		
		return $con;

	}
1051090
public static function getInstance(array $config = [])
        {
            if (!is_object(static::$self)) {
                $className = get_called_class();
                static::$self = new $className($config);
            } else {
                // Add new config settings if given
                if (Arrays::is($config) && count($config) > 0) {
                    static::$self->config($config);
                }
            }

            return static::$self;
        }
1285342
public function connect(array $config)
    {
        $tns = ! empty($config['tns']) ? $config['tns'] : $this->getDsn($config);

        $options = $this->getOptions($config);

        if (array_get($options, 'session_mode') === OCI_CRED_EXT) {
            // External connections can only be used with user / and an empty password
            $config['username'] = '/';
            $config['password'] = null;
        }

        $connection = $this->createConnection($tns, $config, $options);

        return $connection;
    }
1126395
public function getConnectionFromConfiguration(array $config)
    {
        if(empty($config['read']) && !empty($config['solrHost'])) {
            throw new \InvalidArgumentException('Invalid registry data please re-initialize your solr connections');
        }

        return $this->getSolrConnectionForNodes($config['read'], $config['write']);
    }
226878
private function connect($config) {
		try {
			$this->pdoObject = new \PDO(
					$config["type"].':host=' . $config["serverName"] . ';dbname='
					. $config["dbName"] . ';port=' . $config["port"],
					$config["user"], $config["password"]);
			$this->pdoObject->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
			$this->pdoObject->exec("SET CHARACTER SET utf8");

		} catch (\PDOException $e) {
			print "Error!: " . $e->getMessage() . "<br/>";
		}
	}
544504
public function connect(array $config)
    {
        $queue = new PHPRedisQueue(
            $this->redis, $config['queue'], Arr::get($config, 'connection', $this->connection)
        );

        $queue->setExpire(Arr::get($config, 'expire', 60));

        return $queue;
    }