select count(distinct ID) from table
Thinkphp CURD写 $count = $model->where($where)->count('distinct 字段名');