我的 Laravel 應(yīng)用程序中有多個(gè) MySQL 連接到不同的數(shù)據(jù)庫(kù)。我知道我不能用 覆蓋默認(rèn)連接DB::connection,但我想知道是否有辦法在函數(shù)的給定范圍內(nèi)只覆蓋一次。例如我目前:DB::connection('mysql2')->table('users')->select ...DB::connection('mysql2')->table('orders')->insert .........但我希望:DB::connection('mysql2'); // override connection once in this scopeDB::table('users')->select ...DB::table('orders')->insert ...
僅在范圍內(nèi)覆蓋默認(rèn) DB::connection
慕工程0101907
2022-01-08 09:24:01