How to use multiple databases in Laravel

前端 未结 4 1404
清歌不尽
清歌不尽 2020-11-21 23:47

I want to combine multiple databases in my system. Most of the time the database is MySQL; but it may differ in future i.e. Admin can generate such a reports which is

4条回答
  •  粉色の甜心
    2020-11-22 00:06

    In Laravel 5.1, you specify the connection:

    $users = DB::connection('foo')->select(...);
    

    Default, Laravel uses the default connection. It is simple, isn't it?

    Read more here: http://laravel.com/docs/5.1/database#accessing-connections

提交回复
热议问题