protected function reconnect($key, $database)
    {
        $connections = DB::getConnections();
        /** @var MySqlConnection $connection */
        $connection = isset($connections[$key]) ? $connections[$key] : '';

        if (is_object($connection) && $connection->getDatabaseName() != $database) {
            $connection->setDatabaseName($database);
            $connection->reconnect();
        }
    }
protected function reconnect($key, $database)
    {
        $connections = DB::getConnections();
        /** @var MySqlConnection $connection */
        $connection = isset($connections[$key]) ? $connections[$key] : '';

        if (is_object($connection) && $connection->getDatabaseName() != $database) {
            $connection->setDatabaseName($database);
            $connection->reconnect();
        }
    }
protected function reconnect ( $ key , $ database ) { $ connections = DB :: getConnections ( ) ; /** @var MySqlConnection $connection */ $ connection = isset ( $ connections [ $ key ] ) ? $ connections [ $ key ] : '' ; if ( is_object ( $ connection ) && $ connection -> getDatabaseName ( ) != $ database ) { $ connection -> setDatabaseName ( $ database ) ; $ connection -> reconnect ( ) ; } }
Changes platform active connection database name and reconnect to it.
@param string $key The connection key under which you will switch databases, ex. platform, site, etc.
@param string $database The database to reconnect to.
Changes platform active connection database name and reconnect to it .