query()->insertGetId($data); // 返回结果 return $id; } /** * 添加数据 * */ public function edit($id,$data) { // 更新时间 $data['update_time'] = time(); // 写入数据表 $result = $this->query()->where(['id'=>$id])->update($data); // 返回结果 return $result; } /** * 获取单个信息 * */ public function getOne($id,$field=''){ // 返回结果 $result = $this->query()->find($id); // 返回结果 $result = $result ? $result->toArray() : []; // 返回值 return empty($field) ? $result : ( isset($result[$field]) ? $result[$field] : null); } /** * 获取单个信息 * */ public function getList(){ // 返回结果 $list = $this->query()->where([['status','=',0]])->get(['id','phone'])->toArray(); // 返回值 return $list; } }