Пример #1
0
 public function actionPromotion($id = false)
 {
     $this->menu = Category::model()->findAll();
     $this->pageTitle = 'Мобильный мир - акции';
     if ($id) {
         $model = Promotion::model()->findByPk($id);
         $this->render('promotion', array('model' => $model));
     } else {
         $criteria = new CDbCriteria();
         $criteria->order = 'id ASC';
         $count = Promotion::model()->count($criteria);
         $pages = new CPagination($count);
         $pages->pageSize = 2;
         $pages->applyLimit($criteria);
         $model = Promotion::model()->findAll($criteria);
         $this->render('allPromotion', array('model' => $model, 'pages' => $pages));
     }
 }
Пример #2
0
 /**
  * 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 Promotion the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Promotion::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }