使用的illuminate/database
這個(gè)庫(kù),文檔有點(diǎn)沒(méi)看懂:
文檔是這樣說(shuō)的:
// 使用默認(rèn)數(shù)據(jù)庫(kù),等價(jià)于Db::connection('mysql')->select(...);
$users = Db::select(...);
// 使用mysql2
$users = Db::connection('mysql2')->select(...);
// 使用pgsql
$users = Db::connection('pgsql')->select(...);
我數(shù)據(jù)庫(kù)已經(jīng)配置好了,例子很迷惑,怎么就直接select(...)方法了,多個(gè)數(shù)據(jù)庫(kù)的情況下我怎么指定表啊?
我這樣是錯(cuò)誤的:
$sp_category = Db::connection('mysql2')::table('1_sp_category')->get();
能給個(gè)例子嗎,謝謝。
參考:https://stackoverflow.com/questions/26181170/laravel-how-to-use-query-builder-dbtable-with-dbconnection 已自行解決,打擾了。
使用方法為:
$sp_category = Db::connection('mysql2')->table('1_share_category')->get();
參考:https://stackoverflow.com/questions/26181170/laravel-how-to-use-query-builder-dbtable-with-dbconnection 找到答案了,打擾了。