123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- /**
- * Created by PhpStorm.
- * User: sicilon_IT
- * Date: 2020/1/12
- * Time: 21:59
- */
- namespace app\index\model;
- use think\Config;
- use think\Db;
- use think\Model;
- class workerinfomodel extends Model
- {
- protected $table = 't_workerinfo';
- private $db;
- public function __construct()
- {
- parent::__construct();
- //$connection = Config::get('database_labourunion');
- $connection = Config::get('database_labouruniondev');
- $this->db = Db::connect($connection);
- }
- /*
- * 20210813
- */
- public function insinfo($arr)
- {
- if (!isset($arr['createtime']) || empty($arr['createtime'])) {
- $arr['createtime'] = date('Y-m-d H:i:s');
- }
- $id = $this->db->table($this->table)->insert($arr, false, true);
- return empty($id) ? false : $id;
- }
- /***
- * 获取信息
- * 20211009
- * wj
- */
- public function getinfo($where)
- {
- $info = $this->db->table($this->table)->where($where)->find();
- return $info;
- }
- /**
- * 获取列表
- */
- public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
- {
- $sqlObj = $this->db->table($this->table)->where($where);
- if ("count" != $field) {
- $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
- if ($row) {
- $data = $sqlObj->find();
- } else {
- $data = $sqlObj->select();
- }
- } else {
- $data = $sqlObj = $sqlObj->count();
- }
- return $data;
- }
- }
|