DoctorModel.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. namespace app\common\model;
  3. /**
  4. * 员工信息表
  5. * Class StaffModel
  6. * @package app\common\model
  7. */
  8. class DoctorModel extends BaseModel
  9. {
  10. protected $table = 'doctor';
  11. /**
  12. *添加医生
  13. *@param array 医院信息
  14. *@return int 医院id
  15. */
  16. public function doctor_add($params){
  17. return $this->kuyun_insert($params,'');
  18. }
  19. /**
  20. *查询医生单条信息
  21. *@param array 查询条件
  22. *@return array 医生信息
  23. */
  24. public function doctor_find($where){
  25. return $this->kuyun_find($where,'','');
  26. }
  27. /**
  28. *查询所有的医生
  29. *@param array 联合查询
  30. *@param string 查询字段
  31. *@param int 页码
  32. *@param bull 是否查数量
  33. *@return array 医生信息
  34. */
  35. public function doctor_select($join,$field,$page,$is_count){
  36. return $this->kuyun_select('',$join,'',$field,'',$page,$is_count);
  37. }
  38. /**
  39. *编辑医生
  40. *@param array 添加的数据
  41. *@param array 条件
  42. *@return int
  43. */
  44. public function doctor_edit($data,$where){
  45. return $this->kuyun_insert($data,$where);
  46. }
  47. /**
  48. *删除医生
  49. *@param array 删除条件
  50. *@return int 返回删除id
  51. */
  52. public function doctor_delete($where){
  53. return $this->kuyun_delete($where);
  54. }
  55. public function getDoctorPage($page,$pageSize,$condition=[],$is_count = false,$order=''){
  56. $join=[
  57. ['hospital h','doctor.hospital_id=h.hospital_id','LEFT'],
  58. ['department d','doctor.department_id = d.department_id','LEFT']
  59. ];
  60. $this->alias('doctor');
  61. $field=['doctor.*,h.name as hospital_name,d.department_name'];
  62. if($is_count){
  63. $res=$this->where($condition)->page($page,$pageSize)->count();
  64. }else{
  65. if($order){
  66. $this->order($order);
  67. }
  68. if(empty($condition)){
  69. $this->where($condition);
  70. }
  71. $res=$this->join($join)->where($condition)->page($page,$pageSize)->column($field);
  72. }
  73. return $res;
  74. }
  75. }