How to check if connected to database in Laravel 4?

前端 未结 3 2014
隐瞒了意图╮
隐瞒了意图╮ 2021-02-01 19:03

How can I check if laravel is connected to the database? I\'ve searched around and I can\'t find anything that would tell me how this is done.

3条回答
  •  借酒劲吻你
    2021-02-01 19:29

    You can Use the following code :

    try{
       DB::connection()->getDatabaseName();
    }catch(Exception $e){
       echo $e->getMessage();
    }
    

提交回复
热议问题