ServiceLog.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace app\service\model;
  3. use think\Model;
  4. /**
  5. * 工单模型
  6. */
  7. class ServiceLog extends Model
  8. {
  9. /**
  10. * 数据筛选
  11. *
  12. * @access public
  13. * @param mixed $field 字段
  14. * @param mixed $where 条件
  15. * @param mixed $join 关联
  16. * @param mixed $offset 分页开始
  17. * @param mixed $limit 分页大小
  18. * @return array 返回类型
  19. */
  20. public function selectServiceLog($field, $offset, $limit, $where=[], $join=[])
  21. {
  22. $result = $this->field($field);
  23. if (empty($join) === false) {
  24. $result = $result->alias('a');
  25. foreach ($join as $k => $v) {
  26. $result = $result->join($k, $v, 'left');
  27. }
  28. }
  29. if (empty($where) === false) {
  30. $result = $result->where($where);
  31. }
  32. $result = $result->limit($offset, $limit)->order('start_time', 'desc')->select();
  33. return $result;
  34. }//end selectServiceLog()
  35. /**
  36. * 数据总数
  37. *
  38. * @access public
  39. * @param mixed $where 条件
  40. * @return array 返回类型
  41. */
  42. public function countServiceLog($where=[])
  43. {
  44. $result = $this;
  45. if (empty($where) === false) {
  46. $result = $result->where($where);
  47. }
  48. $result = $result->count();
  49. return $result;
  50. }//end countServiceLog()
  51. }