laravel multiple database connections code example
Example 1: DB::transaction
use Illuminate\Support\Facades\DB;
DB::transaction(function () {
DB::update('update users set votes = 1');
DB::delete('delete from posts');
});
Example 2: laravel 8 app with more than one database
$blogs = DB::connection('mysql2')->table("blog")->get();print_r($blogs);
Example 3: laravel 8 app with more than one database
$blogs = DB::table("blog")->get();print_r($blogs);