userlocationmodel.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: sicilon_IT
  5. * Date: 2021/4/30
  6. * Time: 10:55
  7. */
  8. namespace app\index\model;
  9. use think\Model;
  10. class userlocationmodel extends Model{
  11. protected $table='t_userlocation';
  12. public function selinfobyopenid($openid){
  13. $where_arr['openid']=$openid;
  14. $uloction=$this->where($where_arr)->find();
  15. return $uloction;
  16. }
  17. /*
  18. * 20210424
  19. *
  20. */
  21. public function insinfo($arr){
  22. $this->setAttr('id',null)->isUpdate(false)->allowField(true)->save($arr);
  23. return $this->id;
  24. }
  25. /*
  26. * 20210502
  27. * 获取所有数据
  28. */
  29. public function sellist(){
  30. $list=$this->all();
  31. $list=collection($list)->toArray();
  32. return $list;
  33. }
  34. /*
  35. * 20210510
  36. */
  37. public function updinfobyid($id,$updarr){
  38. $where_arr['id']=$id;
  39. $rec=$upd_arr=$this->where($where_arr)->update($updarr);
  40. return $rec;
  41. }
  42. /*
  43. * 20210511
  44. * 获取用户的按省级的统计数据
  45. */
  46. public function selgroupby_p(){
  47. $strsql="select province,count(*) as workcount from t_userlocation group by province";
  48. $rlist=$this->query($strsql);
  49. $rlist=collection($rlist)->toArray();
  50. return $rlist;
  51. }
  52. /*
  53. * 20210511
  54. * 获取用户的按市级的统计数据
  55. */
  56. public function selgroupby_c(){
  57. $strsql="select city,count(*) as workcount from t_userlocation group by city";
  58. $rlist=$this->query($strsql);
  59. $rlist=collection($rlist)->toArray();
  60. return $rlist;
  61. }
  62. /*
  63. * 20210515
  64. * 按项目统计用户数据
  65. */
  66. public function selgroupbyprj(){
  67. $strsql="select prjid,count(*) as workcount from t_userlocation group by prjid";
  68. $rlist=$this->query($strsql);
  69. $rlist=collection($rlist)->toArray();
  70. return $rlist;
  71. }
  72. }