Exemplo n.º 1
0
 /**
  * Lists all UserActivity models.
  * @return mixed
  */
 public function actionIndex()
 {
     $model = new UserActivitySearch();
     $request = Yii::$app->request;
     if ($model->load(Yii::$app->request->post())) {
         if (!$model->hasErrors()) {
             $dbCommand = Yii::$app->db->createCommand("SELECT YEAR(tanggal_lahir) as tanggal_diterbitkan,COUNT(*) as count FROM base WHERE YEAR(tanggal_lahir) BETWEEN '" . $model->dari . "' AND '" . $model->sampai . "' GROUP BY YEAR(tanggal_lahir)");
         }
     } else {
         $dbCommand = Yii::$app->db->createCommand("\n\t\t\t   SELECT YEAR(tanggal_lahir) as tanggal_diterbitkan,COUNT(*) as count FROM base WHERE tanggal_lahir BETWEEN '" . \Yii::$app->formatter->asDate('-30 year', 'php:Y-m-d') . "' AND '" . \Yii::$app->formatter->asDate('now', 'php:Y-m-d') . "' GROUP BY YEAR(tanggal_lahir)\n\t\t\t");
     }
     $query = $dbCommand->queryAll();
     //$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('index', ['query' => $query, 'model' => $model]);
 }
Exemplo n.º 2
0
 /**
  * Lists all UserActivity models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new UserActivitySearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }