SNaRe
4 years ago
2142
24
Laravel

How to connect 2 different databases and Join 2 tables that are on different servers?

Posted 4 years ago by SNaRe

I have 2 different databases and I want to inner join 2 tables in these databases.

I know that this is not the best practice but I need to find a way to do this with LARAVEL.

I can do this with plain PHP by opening 2 connectios. But I am looking for way to do this with laravel.

$users = DB::connection('mysql2')->select(...);'

Adding another connection is the solution but how I will use two databases in 2 different servers in 1 inner join query?

Please sign in or create an account to participate in this conversation.