Esempio n. 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Kjh::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['qh' => $this->qh, 'bai' => $this->bai, 'shi' => $this->shi, 'ge' => $this->ge]);
     return $dataProvider;
 }
Esempio n. 2
0
 /**
  * 展示开奖号码表格
  */
 public function actionShow()
 {
     // 是否包含需要显示的期数,没有在赋值为15
     $num = Yii::$app->request->get('num');
     if ($num == null) {
         $num = 15;
     }
     // 保证需要显示的期数不大于数据库里存在的数据的期数
     if ($num > Kjh::find()->count()) {
         throw new Exception('需要显示的期数不能大于数据库里存在的数据的期数,只能是数字');
     }
     // 从数据库中取出数据 $num
     $temp = Kjh::find()->limit($num)->orderBy('qh DESC')->all();
     $temp2 = array_reverse($temp);
     $model = $this->numbersFormat($temp2);
     return $this->render('show', ['model' => $model]);
 }