Robot.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace app\admin\model;
  3. use think\Model;
  4. /**
  5. * 智能问答模型
  6. */
  7. class Robot extends Model
  8. {
  9. /**
  10. * select数据筛选
  11. *
  12. * @access public
  13. * @param mixed $join 关联
  14. * @param mixed $where 条件
  15. * @param mixed $offset 分页开始
  16. * @param mixed $limit 分页大小
  17. * @param mixed $order 排序
  18. * @return array 返回类型
  19. */
  20. public function selectJoin($join, $where=[], $offset='', $limit='', $order=['robot_updateTime'=>'desc'])
  21. {
  22. $result = $this;
  23. if (empty($join) === false) {
  24. $result = $result->alias('a');
  25. foreach ($join as $k => $v) {
  26. $result = $result->join($k, $v);
  27. }
  28. }
  29. if (empty($where) === false) {
  30. $result = $result->where($where);
  31. }
  32. if (empty($offset) === false && empty($limit) === false) {
  33. $result = $result->limit($offset, $limit);
  34. }
  35. if (empty($order) === false) {
  36. foreach ($order as $k => $v) {
  37. $result = $result->order($k, $v);
  38. }
  39. }
  40. $result = $result->select();
  41. return $result;
  42. }//end selectJoin()
  43. /**
  44. * select数据筛选
  45. *
  46. * @access public
  47. * @param mixed $where 条件
  48. * @return array 返回类型
  49. */
  50. public function count($where=[])
  51. {
  52. $result = $this;
  53. if (empty($where) === false) {
  54. $result = $result->where($where);
  55. }
  56. $result = $result->count();
  57. return $result;
  58. }//end count()
  59. }