예제 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = WA_ZONE::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;
     }
     if ($this->CREATE_TIME) {
         $date = Yii::$app->utilsHelper->convThFormatDate($this->CREATE_TIME, 'dd MM yyyy', 'dd/mm/yyyy');
         $query->andFilterWhere(['between', 'CREATE_TIME', new \yii\db\Expression("to_date('{$date} 00:00:01','dd/mm/yyyy hh24:mi:ss')"), new \yii\db\Expression("to_date('{$date} 23:59:59','dd/mm/yyyy hh24:mi:ss')")]);
     }
     $query->andFilterWhere(['like', 'ZONE_CODE', $this->ZONE_CODE])->andFilterWhere(['like', 'ZONE_NAME_TH', $this->ZONE_NAME_TH])->andFilterWhere(['like', 'ZONE_NAME_EN', $this->ZONE_NAME_EN])->andFilterWhere(['like', 'CREATE_USER_ID', $this->CREATE_USER_ID])->andFilterWhere(['like', 'LAST_UPD_USER_ID', $this->LAST_UPD_USER_ID]);
     return $dataProvider;
 }
예제 #2
0
 /**
  * Finds the WA_ZONE model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return WA_ZONE the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = WA_ZONE::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }