I have two databases db1 and db2 and both of them are same server. my code is

public function test(){
    $connection = ConnectionManager::get('db1'); 
    $results = $connection->execute('select db1.table1.name from db1.table1 join db2 on db1.table1.id = db2.table1.other_id  where db1.table1.id=10')->fetchAll('assoc');
    dd($results);
}

It doesn't work. What should I do? Thanks is advance.

1 Answers

-2
Gaurav Neema On

There is no way to do this directly. You have to query both the databases separately and process the results in your backend(controller).