Skip to content
Advertisement

Changing MySQL database to connect to based on URL parameter in Laravel 8

I have a series of databases named server_1 to server_100. Based on the URL parameter that the users select, I would like to connect to that database. Is there a way to accomplishing this without defining 100 separate connections in .env?

Advertisement

Answer

You have to change database connection on fly and also dont forget to purge connection.

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement