0
我已经尝试了下面的代码来计算特定用户的出席人数,但是表中所有可用用户的计算正在发生。我是laravel的新手,所以我需要帮助。如何在laravel中选择特定的用户ID?
控制器:
$TController =DB::table('tbl_attendancetime')
->select('username','statusid','status_description','user_id')
->groupby('username')
->get();
$TController1 =DB::table('tbl_attendancetime')//->distinct()
->select('statusid')
->where('statusid','=', 0)//->groupBy('user_id')
->get();
$TController2 =DB::table('tbl_attendancetime')
->select('statusid')//->groupby('user_id')
->where('statusid','=', 1)//->distinct()->get(array('user_id'));
//->groupBy('user_id')
->get();
$TController3 =DB::table('tbl_attendancetime')
->select('status_description')//->groupby('user_id')
->where('status_description','=',3)
->groupBy('user_id')
->get();
$TController4 =DB::table('tbl_attendancetime')
->select(
'status_description')//->groupby('user_id')
->where('status_description','4')
->groupBy('user_id')
->get();
$TController5 =DB::table('tbl_attendancetime')
->select(
'status_description')//->groupby('user_id')
->where('status_description','5')
->groupBy('user_id')
->get();
foreach($TController as $row)
{
$a=count($TController1);
$p=count($TController2);
$e=count($TController3);
$s=count($TController4);
$su=count($TController5);
}
我已删除的连接查询,而我想要的信息的所有用户: - >在哪里(“USER_ID”,1)将只授予一个用户,另一个问题是,对于一个用户也会统计整个数据库的天数。 –