Database link laravel framework

Just after the configuration database linking code found how Rom, because there are two files .env and .envexample file, pay attention to the configuration parameters .env document which, for example, I use mysql configuration words in .env

So:

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=8889
DB_DATABASE=shop
DB_USERNAME= root
DB_PASSWORD=123456

Then there can be such a query Controller:

function test(){

  $card = DB::select("select * from card");
  dd($card);

}

Guess you like

Origin www.cnblogs.com/ayanboke/p/11239340.html