Users.php 1.2 KB

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