laravel 打印sql语句
时间:2021-07-01 10:21:17
帮助过:130人阅读
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;
}
打印结果:
laravel 打印sql语句
标签:etc value ret get table question col size ima