Skip to content

[7.x] Add usingConnection method to DatabaseManager#32761

Merged
taylorotwell merged 1 commit intolaravel:7.xfrom
cybercog:add-using-connection-to-database-manager
May 11, 2020
Merged

[7.x] Add usingConnection method to DatabaseManager#32761
taylorotwell merged 1 commit intolaravel:7.xfrom
cybercog:add-using-connection-to-database-manager

Conversation

@antonkomarev
Copy link
Copy Markdown
Contributor

@antonkomarev antonkomarev commented May 11, 2020

This PR adds usingConnection method to Illuminate\Database\DatabaseManager.

It is useful when you want to execute some actions in one connection and then switch back to the original connection.

// Some logic performed on tenant connection

$this->databaseManager->usingConnection('landlord', function () {
    // Some logic performed on landlord connection
});

// Some logic performed on tenant connection

@taylorotwell taylorotwell merged commit 9b65240 into laravel:7.x May 11, 2020
@antonkomarev antonkomarev deleted the add-using-connection-to-database-manager branch May 11, 2020 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants