src/DBAL/ConnectionWrapper.php
public function forceSwitch($dbHost, $dbName, $dbUser, $dbPassword, array $dbOptions = array())
    {
        if ($this->getSession()->has(self::SESSION_CONNECTION_KEY)) {
            $current = $this->getSession()->get(self::SESSION_CONNECTION_KEY);
            if ($current[self::PARAM_HOST] === $dbHost && $current[self::PARAM_DATABASE] === $dbName) {
                return false;
            }
        }

        $this->getSession()->set(self::SESSION_CONNECTION_KEY, array(
            self::PARAM_DRIVER_OPTIONS => $dbOptions,
            self::PARAM_HOST           => $dbHost,
            self::PARAM_DATABASE       => $dbName,
            self::PARAM_USER           => $dbUser,
            self::PARAM_PASSWORD       => $dbPassword,
        ));

        if ($this->isConnected()) {
            $this->close();
        }

        return true;
    }
public function forceSwitch($dbHost, $dbName, $dbUser, $dbPassword, array $dbOptions = array())
    {
        if ($this->getSession()->has(self::SESSION_CONNECTION_KEY)) {
            $current = $this->getSession()->get(self::SESSION_CONNECTION_KEY);
            if ($current[self::PARAM_HOST] === $dbHost && $current[self::PARAM_DATABASE] === $dbName) {
                return false;
            }
        }

        $this->getSession()->set(self::SESSION_CONNECTION_KEY, array(
            self::PARAM_DRIVER_OPTIONS => $dbOptions,
            self::PARAM_HOST           => $dbHost,
            self::PARAM_DATABASE       => $dbName,
            self::PARAM_USER           => $dbUser,
            self::PARAM_PASSWORD       => $dbPassword,
        ));

        if ($this->isConnected()) {
            $this->close();
        }

        return true;
    }
public function forceSwitch ( $ dbHost , $ dbName , $ dbUser , $ dbPassword , array $ dbOptions = array ( ) ) { if ( $ this -> getSession ( ) -> has ( self :: SESSION_CONNECTION_KEY ) ) { $ current = $ this -> getSession ( ) -> get ( self :: SESSION_CONNECTION_KEY ) ; if ( $ current [ self :: PARAM_HOST ] === $ dbHost && $ current [ self :: PARAM_DATABASE ] === $ dbName ) { return false ; } } $ this -> getSession ( ) -> set ( self :: SESSION_CONNECTION_KEY , array ( self :: PARAM_DRIVER_OPTIONS => $ dbOptions , self :: PARAM_HOST => $ dbHost , self :: PARAM_DATABASE => $ dbName , self :: PARAM_USER => $ dbUser , self :: PARAM_PASSWORD => $ dbPassword , ) ) ; if ( $ this -> isConnected ( ) ) { $ this -> close ( ) ; } return true ; }
Force a switch of database connection.

@param  string $dbHost
@param  string $dbName
@param  string $dbUser
@param  string $dbPassword
@param  array  $dbOptions

@return bool
Force a switch of database connection .