public function actionOutbound() { if (isset($_GET['id'])) { $model = Cooperation::model()->findByPk($_GET['id']); $this->render('detail', array('model' => $model)); } else { $criteria = new CDbCriteria(); $criteria->select = '*'; $criteria->condition = 'status=:status AND t.group=:group'; $criteria->params = array(':status' => 1, ':group' => 'outbound'); $criteria->order = 'sort_order ASC ,co_id ASC'; $co_total = Cooperation::model()->count($criteria); $pages = new CPagination($co_total); $pages->setPageSize(20); $pages->applyLimit($criteria); $model = Cooperation::model()->findAll($criteria); $this->render('outbound', array('model' => $model, 'pages' => $pages)); } }
/** * 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 Cooperation the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Cooperation::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }