public function actionIndex() { $this->pageTitle = "分页类"; //使用分页类 $page = new Page(BbsInfo::model()->count(), 3); $bbsInfo = BbsInfo::model()->findAll(array("limit" => $page->listRows, "offset" => $page->firstRow)); $data = array("bbsInfo" => $bbsInfo, "pageList" => $page->show()); $this->render("index", $data); }
public function actionUpdate($bbsId) { //$result = BbsInfo::model()->updateAll($_POST,"bbsId={$bbsId}"); $result = BbsInfo::model()->updateByPk($bbsId, $_POST); if ($result > 0) { $this->redirect(__APP__ . "/query/index"); } else { $this->redirect(__APP__ . "/update/index/bbsId/{$bbsId}"); } }
public function actionIndex($currentPage = 1) { $this->pageTitle = "数据库分页"; //分页变量 $pageSize = 3; $totalRow = BbsInfo::model()->count(); $totalPage = ceil($totalRow / $pageSize); $start = ($currentPage - 1) * $pageSize; $bbsInfo = BbsInfo::model()->findAll(array("limit" => $pageSize, "offset" => $start)); $data = array("bbsInfo" => $bbsInfo, "currentPage" => $currentPage, "totalPage" => $totalPage); $this->render("index", $data); }
public function actionAdd() { $model = BbsInfo::model(); // 使用$model->$var来绑定数据 $model->title = $_POST['title']; $model->userId = $_SESSION['userMsg']['userId']; $model->typeId = $_POST['typeId']; $model->face = $_POST['face']; $model->content = $_POST['content']; // save保存方法保存数据 $result = $model->save(); // 跳转 $this->redirect("index.php?r=reaction/index/act/addBbs/rst/{$result}"); }
public function actionIndex() { $this->pageTitle = "论坛首页"; // 论坛公告 $notices = Notices::model()->find(); // 讨论区类别 $bbsType = BbsType::model()->findAll(); // 话题计数 $bbsCount = BbsInfo::model()->count(); // 回帖计数 $revCount = Reviews::model()->count(); // 用户计数 $userCount = UserInfo::model()->count(); // 绑定数据 $data = array('notices' => $notices, 'bbsType' => $bbsType, 'bbsCount' => $bbsCount, 'revCount' => $revCount, 'userCount' => $userCount); $this->render('index', $data); }
/** * 通过获取的bbsId来删除话题,只有发帖人和超级管理员能删除 * @param int $bbsId 论坛话题ID */ public function actionDelete($bbsId) { $result = BbsInfo::model()->deleteByPK("{$bbsId}"); $this->redirect('index.php?r=reaction/index/act/delArtical/rst/' . $result . 'bbsId/' . $bbsId); }
public function actionDelete($bbsId) { //$result = BbsInfo::model()->deleteAll("bbsId={$bbsId}"); $result = BbsInfo::model()->deleteByPk($bbsId); $this->redirect(__APP__ . "/query/index"); }