コード例 #1
0
 public function actionIndex()
 {
     $dataProvider = new CActiveDataProvider('Players', array('criteria' => array('select' => '`id`, `nick`, `steam_id`, `last_seen`, ' . Players::sql_skill_formula() . ' AS `skill`', 'order' => '`skill` DESC, `id` ASC', 'condition' => 'last_seen > ' . (time() - 60 * 60 * 24 * 7)), 'pagination' => array('pageSize' => Yii::app()->config->bans_per_page)));
     $model = new Players('search');
     $model->unsetAttributes();
     if (isset($_GET['Players'])) {
         $model->attributes = $_GET['Players'];
     }
     $this->render('index', array('dataProvider' => $dataProvider, 'model' => $model));
 }
コード例 #2
0
ファイル: SiteController.php プロジェクト: DmitriyS/CS-Bans
 /**
  * Главная страница сайта
  */
 public function actionIndex()
 {
     // Вытаскиваем 10 последних банов
     $dependecy = new CDbCacheDependency('SELECT MAX(`bid`) FROM {{bans}}');
     $bans = new CActiveDataProvider(Bans::model()->cache(300, $dependecy), array('criteria' => array('condition' => Yii::app()->config->auto_prune ? 'expired = 0' : null, 'order' => 'bid DESC', 'limit' => 10), 'pagination' => false));
     // Вытаскиваем 10 лучших игроков
     $dependecy = new CDbCacheDependency('SELECT MAX(`id`) FROM `bio_players`');
     $players = new CActiveDataProvider(Players::model()->cache(300, $dependecy), array('criteria' => array('select' => '`id`, `nick`, ' . Players::sql_skill_formula() . ' AS `skill`', 'order' => '`skill` DESC, `id` ASC', 'condition' => 'last_seen > ' . (time() - 60 * 60 * 24 * 7), 'limit' => 10), 'pagination' => false));
     $this->render('index', array('bans' => $bans, 'players' => $players, 'servers' => Serverinfo::model()->findAll()));
 }