mardi 6 février 2018

Laravel dynamic database connections

I going to use dynamic database connections in backend.

        Config::set('database.connections._pgsql.host', $connection->host);
        Config::set('database.connections._pgsql.port', $connection->port);
        Config::set('database.connections._pgsql.username', $connection->account_name);
        Config::set('database.connections._pgsql.password', $connection->password);
        Config::set('database.connections._pgsql.database', $connection->initial_db);

        DB::purge('_pgsql');
        DB::reconnect('_pgsql');

As you see, I have to change db config every request to use dynamic db connections. If there are concurrent requests with different db connections then how can I handle these requests and connections?

Please help me.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire