Users.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 $data 数据
  31. * @param mixed $where 条件
  32. * @return array 返回类型
  33. */
  34. public function updateUsers($where, $data)
  35. {
  36. $result = $this->where($where)->update($data);
  37. return $result;
  38. }//end updateUsers()
  39. /**
  40. * 单个数据筛选
  41. *
  42. * @access public
  43. * @param mixed $field 字段
  44. * @param mixed $where 条件
  45. * @param mixed $join 关联
  46. * @return array 返回类型
  47. */
  48. public function findInfo($field, $where=[], $join=[])
  49. {
  50. $result = $this->field($field);
  51. if (empty($join) === false) {
  52. $result = $result->alias('a');
  53. foreach ($join as $k => $v) {
  54. $result = $result->join($k, $v);
  55. }
  56. }
  57. if (empty($where) === false) {
  58. $result = $result->where($where);
  59. }
  60. $result = $result->find();
  61. return $result;
  62. }//end findUsers()
  63. }