public function delete() { $id = I('id'); $model = new ReplyModel(); $post = $model->find($id); if (empty($post)) { $this->error('回复不存在'); } $result = $model->delete($id); if ($result === false) { $this->error('删除失败'); } else { $this->success('删除成功'); } }
/** * 删除回复 */ public function replyDelete() { $this->checkLogin(); $id = I('id'); $model = new ReplyModel(); $post = $model->find($id); if (empty($post)) { $this->error('回复不存在'); } if ($post['userId'] != $this->user['userId']) { $this->error('你无权删除'); } $result = $model->delete($id); if ($result === false) { $this->error('删除失败'); } else { $callback = I('callback'); if (empty($callback)) { $callback = U('replies'); } $this->success('删除成功', $callback); } }