コード例 #1
0
 public function loadModel($id)
 {
     $model = GalleryImage::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
コード例 #2
0
ファイル: DefaultController.php プロジェクト: CNAEF/go9999_v2
 /**
  * Index Page, for now just render all static content.
  */
 public function actionIndex()
 {
     //TODO add cache logic later.
     //load last 5 news
     $criteria = new CDbCriteria();
     $criteria->limit = 5;
     $criteria->order = 'n_id DESC';
     $news = News::model()->findAll($criteria);
     //load last 9 suggestion images
     $criteria = new CDbCriteria();
     $criteria->limit = 9;
     $criteria->order = 'id DESC';
     $criteria->condition = 'is_recommend = 1';
     $images = GalleryImage::model()->findAll($criteria);
     $this->render('index', array('news' => $news, 'posts' => BlogPosts::post(), 'notices' => BlogPosts::notice(), 'images' => $images));
 }