workerinfomodel.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: sicilon_IT
  5. * Date: 2020/1/12
  6. * Time: 21:59
  7. */
  8. namespace app\index\model;
  9. use think\Config;
  10. use think\Db;
  11. use think\Model;
  12. class workerinfomodel extends Model
  13. {
  14. protected $table = 't_workerinfo';
  15. private $db;
  16. public function __construct()
  17. {
  18. parent::__construct();
  19. //$connection = Config::get('database_labourunion');
  20. $connection = Config::get('database_labouruniondev');
  21. $this->db = Db::connect($connection);
  22. }
  23. /*
  24. * 20210813
  25. */
  26. public function insinfo($arr)
  27. {
  28. if (!isset($arr['createtime']) || empty($arr['createtime'])) {
  29. $arr['createtime'] = date('Y-m-d H:i:s');
  30. }
  31. $id = $this->db->table($this->table)->insert($arr, false, true);
  32. return empty($id) ? false : $id;
  33. }
  34. /***
  35. * 获取信息
  36. * 20211009
  37. * wj
  38. */
  39. public function getinfo($where)
  40. {
  41. $info = $this->db->table($this->table)->where($where)->find();
  42. return $info;
  43. }
  44. /**
  45. * 获取列表
  46. */
  47. public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
  48. {
  49. $sqlObj = $this->db->table($this->table)->where($where);
  50. if ("count" != $field) {
  51. $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
  52. if ($row) {
  53. $data = $sqlObj->find();
  54. } else {
  55. $data = $sqlObj->select();
  56. }
  57. } else {
  58. $data = $sqlObj = $sqlObj->count();
  59. }
  60. return $data;
  61. }
  62. }