Laravel 框架查詢執行的 SQL 語句

Yoger發表於2019-07-11
//有些查詢條件被拼接的實在難以捋,記錄一下這麼好用的功能
public function index(Request $request)\
 {

 //開啟
 DB::enableQueryLog();

 $this->passRecordRepository->pushCriteria(new RequestCriteria($request));
  $this->passRecordRepository->pushCriteria(new PassRecordSearchCriteria($request));
  $this->passRecordRepository->pushCriteria(new DeviceCriteria($request));
  $this->passRecordRepository->pushCriteria(new DateCriteria($this->getStartDate($request) , $this->getEndDate($request)));
  $passRecords = $this->passRecordRepository->orderBy('ts', 'DESC')->paginate(100);

  //列印
  dd(DB::getQueryLog());
 }
本作品採用《CC 協議》,轉載必須註明作者和本文連結

相關文章