【TP3.2.3】根据字段统计条数

//        省份查询
        $province = M('hospital') -> field('area as label,count(*) as value') -> group('area') -> select();

输出结果如下所示:

array(31) {
  [0] => array(2) {
    ["label"] => string(6) "上海"
    ["value"] => string(5) "25548"
  }
  [1] => array(2) {
    ["label"] => string(6) "云南"
    ["value"] => string(4) "6465"
  }
  [2] => array(2) {
    ["label"] => string(9) "内蒙古"
    ["value"] => string(4) "7610"
  }
  [3] => array(2) {
    ["label"] => string(6) "北京"
    ["value"] => string(5) "41644"
  }
  [4] => array(2) {
    ["label"] => string(6) "吉林"
    ["value"] => string(5) "12642"
  }
  [5] => array(2) {
    ["label"] => string(6) "四川"
    ["value"] => string(5) "27972"
  }
  [6] => array(2) {
    ["label"] => string(6) "天津"
    ["value"] => string(4) "9682"
  }
  [7] => array(2) {
    ["label"] => string(6) "宁夏"
    ["value"] => string(4) "5693"
  }
  [8] => array(2) {
    ["label"] => string(6) "安徽"
    ["value"] => string(5) "18968"
  }
  [9] => array(2) {
    ["label"] => string(6) "山东"
    ["value"] => string(5) "46775"
  }
  [10] => array(2) {
    ["label"] => string(6) "山西"
    ["value"] => string(5) "14149"
  }
  [11] => array(2) {
    ["label"] => string(6) "广东"
    ["value"] => string(5) "51940"
  }
  [12] => array(2) {
    ["label"] => string(6) "广西"
    ["value"] => string(4) "8223"
  }
  [13] => array(2) {
    ["label"] => string(6) "新疆"
    ["value"] => string(4) "4392"
  }
  [14] => array(2) {
    ["label"] => string(6) "江苏"
    ["value"] => string(5) "35832"
  }
  [15] => array(2) {
    ["label"] => string(6) "江西"
    ["value"] => string(5) "16371"
  }
  [16] => array(2) {
    ["label"] => string(6) "河北"
    ["value"] => string(5) "29154"
  }
  [17] => array(2) {
    ["label"] => string(6) "河南"
    ["value"] => string(5) "29559"
  }
  [18] => array(2) {
    ["label"] => string(6) "浙江"
    ["value"] => string(5) "31941"
  }
  [19] => array(2) {
    ["label"] => string(6) "海南"
    ["value"] => string(4) "2590"
  }
  [20] => array(2) {
    ["label"] => string(6) "湖北"
    ["value"] => string(5) "23529"
  }
  [21] => array(2) {
    ["label"] => string(6) "湖南"
    ["value"] => string(5) "19571"
  }
  [22] => array(2) {
    ["label"] => string(6) "甘肃"
    ["value"] => string(4) "5236"
  }
  [23] => array(2) {
    ["label"] => string(6) "福建"
    ["value"] => string(5) "16886"
  }
  [24] => array(2) {
    ["label"] => string(6) "西藏"
    ["value"] => string(3) "179"
  }
  [25] => array(2) {
    ["label"] => string(6) "贵州"
    ["value"] => string(4) "7445"
  }
  [26] => array(2) {
    ["label"] => string(6) "辽宁"
    ["value"] => string(5) "16988"
  }
  [27] => array(2) {
    ["label"] => string(6) "重庆"
    ["value"] => string(5) "11355"
  }
  [28] => array(2) {
    ["label"] => string(6) "陕西"
    ["value"] => string(5) "15026"
  }
  [29] => array(2) {
    ["label"] => string(6) "青海"
    ["value"] => string(3) "823"
  }
  [30] => array(2) {
    ["label"] => string(9) "黑龙江"
    ["value"] => string(5) "15140"
  }
}

 

posted @ 2019-08-26 16:25  李文和  阅读(1297)  评论(0编辑  收藏  举报