我使用laravel的listen方法为每个查询创建日志。我得到所有这样的sql查询:
\DB::listen(function($q) {
$query = $q->sql;
//Save in logn
});
我想获取查询是更新还是删除时修改的列数。
你能帮我吗?
答案 0 :(得分:0)
in your controller
(1) using Eloquent:
use App\Project;
public function totalprojects()
{
$total_projects = Project::count();
return view('summarys.summary')->with(['total'=>$total_projects]);
}
(2) using Query Builder:
use DB;
public function totalprojects()
{
$total_projects = DB::table('projects')->count();
return view('summarys.summary')->with(['total'=>$total_projects]);
}
in your blade :
<p>{{ $total }}</p>