src/Database.php
public function getConnection($name = null, $forceNew = false) {
		if (!$forceNew && isset($this->connections[$name])) {
			return $this->connections[$name];
		}

		$config = $this->getConnectionConfig($name);

		if (!$config) {
			return null;
		}

		$pdoArgs = [$config['dsn'], $config['username'], $config['password']];
		$options = [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION];

		if (isset($config['options'])) {
			$options = $config['options'] + $options;
		}
		$pdoArgs[] = $options;

		$this->connections[$name] = new PDO(...$pdoArgs);

		return $this->connections[$name];
	}
public function getConnection($name = null, $forceNew = false) {
		if (!$forceNew && isset($this->connections[$name])) {
			return $this->connections[$name];
		}

		$config = $this->getConnectionConfig($name);

		if (!$config) {
			return null;
		}

		$pdoArgs = [$config['dsn'], $config['username'], $config['password']];
		$options = [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION];

		if (isset($config['options'])) {
			$options = $config['options'] + $options;
		}
		$pdoArgs[] = $options;

		$this->connections[$name] = new PDO(...$pdoArgs);

		return $this->connections[$name];
	}
public function getConnection ( $ name = null , $ forceNew = false ) { if ( ! $ forceNew && isset ( $ this -> connections [ $ name ] ) ) { return $ this -> connections [ $ name ] ; } $ config = $ this -> getConnectionConfig ( $ name ) ; if ( ! $ config ) { return null ; } $ pdoArgs = [ $ config [ 'dsn' ] , $ config [ 'username' ] , $ config [ 'password' ] ] ; $ options = [ PDO :: ATTR_ERRMODE => PDO :: ERRMODE_EXCEPTION ] ; if ( isset ( $ config [ 'options' ] ) ) { $ options = $ config [ 'options' ] + $ options ; } $ pdoArgs [ ] = $ options ; $ this -> connections [ $ name ] = new PDO ( ... $ pdoArgs ) ; return $ this -> connections [ $ name ] ; }
Get a connection by name.

@param string $name Optional. Connection name.
@param bool $forceNew Optional. Create a new connection or reuse the old one if exists.
@return \PDO|null
Get a connection by name .