PHP laravel框架打印mysql语句

子车新立
2023-12-01

laravel打印sql语句

DB::connection()->enableQueryLog();#开启执行日志
$a = self::where(['investorid'=>$id])->whereBetween('inserttime',[$start,$end])->where('deposit','>',0)->orderBy('id','asc')->Paginate(20);
var_dump(DB::getQueryLog());

打印结果

array(3) {
    ["query"]=>
    string(75) "select count(*) as aggregate from `xsh_shop_all_member` where `shop_id` = ?"
    ["bindings"]=>
    array(1) {
      [0]=>
      string(2) "27"
    }
    ["time"]=>
    float(3.5)
  }
 类似资料: