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); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Notices the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Notices::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }