workermodel.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /*
  3. * @Author: wang jun
  4. * @Date: 2021-09-27 08:39:30
  5. * @Last Modified by: wang jun
  6. * @Last Modified time: 2021-09-27 10:40:35
  7. */
  8. namespace app\index\model;
  9. use think\Model;
  10. class workermodel extends Model
  11. {
  12. protected $table = 't_worker';
  13. public function insertData($data)
  14. {
  15. $id = $this->insertGetId($data);
  16. return empty($id) ? false : $id;
  17. }
  18. public function getInfo($where, $field = "*", $row = true)
  19. {
  20. $info = $this->field($field)->where($where);
  21. if ($row) {
  22. $info = $info->find();
  23. } else {
  24. $info = $info->select();
  25. }
  26. return empty($info) ? false : $info;
  27. }
  28. public function updateinfo($where, $updateData)
  29. {
  30. $row = $this->where($where)->update($updateData);
  31. return empty($row) ? false : $row;
  32. }
  33. public function deleteinfo($where)
  34. {
  35. $row = $this->where($where)->delete();
  36. return empty($row) ? false : $row;
  37. }
  38. /***
  39. * 获取全部字段名
  40. * 20211103
  41. * wj
  42. */
  43. public function gettablefields()
  44. {
  45. $sql = "desc " . $this->table;
  46. $fiekds = $this->query($sql);
  47. return $fiekds;
  48. }
  49. }