laravel打印原生语句

laravel中快捷方便的打印语句的方法
步骤一:
DB::connection()->enableQueryLog();
$data["banner"] = WebsiteBanner::leftJoin("website_banner_category","website_banner.wb_category_id","=","website_banner_category.wbc_id")
->where("website_banner_category.wbc_code","index")
->where("website_banner.wb_start_time","<=",time())
->where("website_banner.wb_end_time",">=",time())
->select("website_banner.wb_name","website_banner.wb_image","website_banner.wb_url")
->get();
第二步:
$carNamedata = DB::getQueryLog();
第三步:
echo "<pre>"; var_dump($carNamedata);
打印结果

可以查询sql运行时间和连接对象



 
posted on 2018-11-12 16:25  kevin_yang123  阅读(478)  评论(0编辑  收藏  举报