123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- namespace app\common\model;
- use think\Model;
- /**
- * 手环类型 1 接受信息 历史数据
- *
- * @author wj
- * @date 2023-08-14
- */
- class TestShoneReceiveInfoRecode extends Model
- {
- protected $table = "test_shouhuan_one_receive_info_recode";
- public function insertData($data)
- {
- $data = $this->formatData($data);
- if (empty($data)) {
- return false;
- }
- $id = $this->insertGetId($data);
- return $id ? $id : false;
- }
- public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
- {
- $sqlObj = $this->where($where);
- if ("count" != $field) {
- if (empty($size)) {
- $sqlObj = $sqlObj->field($field)->order($order)->group($group);
- } else {
- $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
- }
- if ($row) {
- $data = $sqlObj->find();
- } else {
- $data = $sqlObj->select();
- }
- } else {
- $data = $sqlObj->count();
- }
- return $data;
- }
- /**
- * 根据id删除信息
- *
- * @param [type] $id
- * @return void
- * @author wj
- * @date 2023-08-14
- */
- public function deleteinfobyid($id)
- {
- $where = ['id' => $id];
- $row = $this->where($where)->delete();
- return empty($row) ? false : $row;
- }
- public function updateinfo($where, $updateData)
- {
- $row = $this->where($where)->update($updateData);
- return empty($row) ? false : $row;
- }
- private function formatData($data)
- {
- $useData = [];
- $fields = $this->getTableFields();
- foreach ($data as $key => $value) {
- if (in_array($key, $fields)) {
- $useData[$key] = $value;
- }
- }
- return $useData;
- }
- 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;
- }
- }
|