且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在应用程序运行时使用Laravel连接到其他数据库?

更新时间:2022-01-15 22:23:09

您可以使用Config :: set方法来即时更改基础配置-到另一个数据库连接,假设这就是您的意思。

You can use the Config::set method to change your underlying config on the fly - to another database connection, assuming that is what you mean.

Config::set("database.connections.mysql", [
    "host" => "...",
    "database" => "...",
    "username" => "...",
    "password" => "...
]);