laravel 打印sql语句

public function getCurrencyOrder($user_id=70,$pid=252,$register=['register:first'])
    {
        DB::connection()->enableQueryLog(); // 开启查询日志
        $data=CurrencyOrder::selectRaw("sum(amount) AS total")
            ->where('owner_id',$user_id)
            ->where('target_id',$pid)
            ->where('type',1)
            ->whereIn('target_type',$register)
            ->value('total');
//        dd(DB::table('question')); // 要查看的sql
        $queries = DB::getQueryLog(); // 获取查询日志
      dd($queries);
if(!$data){ $data=0; } return $data; }
打印结果:

 

 
posted @ 2018-12-03 17:31  心之所依  阅读(1413)  评论(0编辑  收藏  举报