protected function findModel($id) { if (($model = Jianli::find()->where(['and', 'id=' . $id])->One()) !== null) { return $model; } else { throw new NotFoundHttpException('你所查找的网页不存在'); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Jianli::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'end_at' => $this->end_at, 'views' => $this->views]); $query->andFilterWhere(['like', 'xingming', $this->xingming])->andFilterWhere(['like', 'xingbie', $this->xingbie])->andFilterWhere(['like', 'nianling', $this->nianling])->andFilterWhere(['like', 'xueli', $this->xueli])->andFilterWhere(['like', 'xiangguanzhengshu', $this->xiangguanzhengshu])->andFilterWhere(['like', 'yingpingzhiwei', $this->yingpingzhiwei])->andFilterWhere(['like', 'qiwangxinzi', $this->qiwangxinzi])->andFilterWhere(['like', 'gerenjianjie', $this->gerenjianjie])->andFilterWhere(['like', 'qitayaoqiu', $this->qitayaoqiu])->andFilterWhere(['like', 'lianxidianhua', $this->lianxidianhua])->andFilterWhere(['like', 'author', $this->author])->andFilterWhere(['like', 'jobtype', $this->jobtype]); return $dataProvider; }
/** * Finds the Jianli model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Jianli the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Jianli::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }