$cjrili_list = CjriliModel::select(); $cjrili_group = Db::query("SELECT time, count(distinct country) as country_row_num, count(*) as time_row_num, country FROM think_cjrili where 1 GROUP BY time"); $cjrili_group_country = Db::query("SELECT country, count(*) as country_row_num FROM think_cjrili where 1 GROUP BY country"); foreach ($cjrili_list as $key => $value) { foreach ($cjrili_group as $k => $v) { if($value['time']==$v['time']){ $cjrili_list[$key]['time_row_num'] = $v['time_row_num']; $cjrili_group[$k]['time'] = ''; } } foreach ($cjrili_group_country as $k2 => $v2) { if($value['country']==$v2['country']){ $cjrili_list[$key]['country_row_num'] = $v2['country_row_num']; $cjrili_group_country[$k2]['country'] = ''; } } }