1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- /*
- * @Author: wang jun
- * @Date: 2022-01-18 09:43:33
- * @Last Modified by: wang jun
- * @Last Modified time: 2022-01-18 16:58:11
- */
- namespace app\index\model;
- use think\Model;
- class companymodel extends Model
- {
- protected $table = 't_company';
- public function insertData($data)
- {
- if (!isset($data['create_time']) || empty($data['create_time']) || !is_string($data['create_time'])) {
- $data['create_time'] = date("Y-m-d H:i:s");
- }
- $id = $this->insertGetId($data);
- return empty($id) ? false : $id;
- }
- public function getInfo($where, $field = "*", $row = true)
- {
- $info = $this->field($field)->where($where);
- if ($row) {
- $info = $info->find();
- } else {
- $info = $info->select();
- }
- return empty($info) ? false : $info;
- }
- public function updateinfo($where, $updateData)
- {
- $row = $this->where($where)->update($updateData);
- return empty($row) ? false : $row;
- }
- public function deleteinfo($where)
- {
- $row = $this->where($where)->delete();
- return empty($row) ? false : $row;
- }
- public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
- {
- $sqlObj = $this->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;
- }
- /**
- * 根据id获取信息
- * wj
- * 20220118
- */
- public function getinfobyid($id)
- {
- $where = ['id' => $id];
- $info = $this->where($where)->find();
- return $info;
- }
- /**
- * 根据id修改数据
- * wj
- * 20220118
- */
- public function updatebyid($id, $updateData)
- {
- $where = ['id' => $id];
- $row = $this->where($where)->update($updateData);
- return $row;
- }
- }
|