12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- namespace app\common\model;
- use think\Model;
- /**
- * 手环一发送列表
- *
- * @author wj
- * @date 2023-08-14
- */
- class TestShoneSendListModel extends Model
- {
- protected $table = "test_shouhuan_one_send_list";
- 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;
- }
- }
|