ChatLog.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. namespace app\service\model;
  3. use think\Model;
  4. /**
  5. * 会话记录模型
  6. */
  7. class ChatLog extends Model
  8. {
  9. /**
  10. * 数据筛选
  11. *
  12. * @access public
  13. * @param mixed $field 字段.
  14. * @param mixed $offset 分页开始.
  15. * @param mixed $limit 分页大小.
  16. * @param mixed $where 条件.
  17. * @return array 返回类型
  18. */
  19. public function selectChatLog($field, $offset, $limit, $where=[])
  20. {
  21. $result = $this->field($field);
  22. if (empty($where) === false) {
  23. $result = $result->where($where);
  24. }
  25. $result = $result->limit($offset, $limit)->order('time_line', 'desc')->select();
  26. return $result;
  27. }//end selectChatLog()
  28. /**
  29. * 数据总数
  30. *
  31. * @access public
  32. * @param mixed $where 条件
  33. * @return array 返回类型
  34. */
  35. public function countChatLog($where=[])
  36. {
  37. $result = $this;
  38. if (empty($where) === false) {
  39. $result = $result->where($where);
  40. }
  41. $result = $result->count();
  42. return $result;
  43. }//end countChatLog()
  44. /**
  45. * 用户数据筛选
  46. *
  47. * @access public
  48. * @param mixed $field 字段
  49. * @param mixed $offset 分页开始
  50. * @param mixed $limit 分页大小
  51. * @param mixed $where 条件
  52. * @param mixed $whereOr 条件
  53. * @return array 返回类型
  54. */
  55. public function userChatLog($field, $where, $whereOr, $offset, $limit)
  56. {
  57. $result = $this
  58. ->field($field)
  59. ->where($where)
  60. ->whereOr($whereOr)
  61. ->limit($offset, $limit)
  62. ->order('time_line', 'desc')
  63. ->select();
  64. return $result;
  65. }//end userChatLog()
  66. /**
  67. * 用户数据总数
  68. *
  69. * @access public
  70. * @param mixed $where 条件.
  71. * @param mixed $whereOr 条件.
  72. * @return array 返回类型
  73. */
  74. public function userChatLogCount($where, $whereOr)
  75. {
  76. $result = $this->where($where)->whereOr($whereOr)->count();
  77. return $result;
  78. }//end userChatLogCount()
  79. }