query()->insertGetId($data); // 如果操作失败 if( !$id ) return ['error'=>'新增失败']; // 返回结果 return $id; } /** * 添加数据 * */ public function edit($id,$data) { // 更新时间 $data['update_time'] = time(); // 写入数据表 $result = $this->query()->where(['id'=>$id])->update($data); // 如果操作失败 if( !$result ) return ['error'=>'修改失败']; // 返回结果 return $result; } }