Laravel 打印 sql 語句

\DB::connection()->enableQueryLog();

// 查詢數據庫信息...
$data = Subject::where('subject_id', 1)->first();

$queries = \DB::getQueryLog();
dd($queries);

Response

array:1 [
  0 => array:3 [
    "query" => "select * from `subjects` where `subject_id` = ? limit 1"
    "bindings" => array:1 [
      0 => 1
    ]
    "time" => 3.78
  ]
]
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章