在计数的时候,如果想要排除某个字段重复的记录,应该用
$total = $User->where($where)->count('distinct id');
而不是
$total = $User->distinct(true)->where($where)->field('id')->count();
因为可能在连表查询时,失效
在计数的时候,如果想要排除某个字段重复的记录,应该用
$total = $User->where($where)->count('distinct id');
而不是
$total = $User->distinct(true)->where($where)->field('id')->count();
因为可能在连表查询时,失效
微信扫码登录