public function doPost() { try { $id = I('id'); $title = I('title'); $content = I('content'); $data = array('title' => $title, 'content' => $content); $model = new PostModel(); if ($model->where(array('postId' => $id))->save($data) === false) { throw new Exception('编辑失败'); } $this->success('编辑成功', U('post/index')); } catch (Exception $e) { $this->error($e->getMessage()); } }
/** * 处理帖子编辑 */ public function postDoPost() { $this->checkLogin(); try { $id = I('id'); $title = I('title'); $content = I('content'); $data = array('title' => $title, 'content' => $content); $model = new PostModel(); if ($model->where(array('postId' => $id))->save($data) === false) { throw new Exception('编辑失败'); } $callback = session('threadUpdateCallback'); if (empty($callback)) { $callback = U('posts'); } session('threadUpdateCallback', null); $this->success('编辑成功', $callback); } catch (Exception $e) { $this->error($e->getMessage()); } }