Support the ongoing development of Laravel.io →
posted 9 years ago
Database
Last updated 2 years ago.
0

Your mean is multi database connection or multi table in a database?

0

@tuyenlaptrinh // As you see in my code example, I meant multiple databases. @Xum // That's multiple connections, not multiple databases.

0

You mean query multi database in one query for an result?

Last updated 9 years ago.
0
Solution

@moon0326, you can prefix database name to table name:

DB::table('dbname.tablename')->get();
Last updated 9 years ago.
0

if you created connections in database.php it is possible to change it onthefly with setConnection("connection_name") if you use Elouquent.

If you use DB you can do it DB::connection("connection_name")

0

@tuyenlaptrinh // No. I just want to query against a different D.B

@Xum // That's the one! Thank you :) @jernejrostan // Thanks. I will keep that in mind.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

moon0326 moon0326 Joined 8 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.