lundi 11 juillet 2016

Joining in laravel with two connection

I have two connection in laravel, and I want to connect both

I tried like this

$response = DB::connection('connection1')->table('table1 as t1');
$response->DB::connection('connection2')->leftJoin('table2 as t2', 't2.t1_id','=','t2.id')
->get();

But query fails, how to join this, please help.

Just like I can do in mysql like this,

SELECT *
FROM [MyDatabaseOnDB1].[dbo].[MyTable] tab1
INNER JOIN [DB2].[MyDatabaseOnDB2].[dbo].[MyOtherTable] tab2
    ON tab1.ID = tab2.ID

How can do this in laravel.

Please comment, If you give me negative votes please..

Aucun commentaire:

Enregistrer un commentaire