/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { /** * 根据参数选择展示的商品 * @var dis=>1 不现实的 0=>显示的 */ $display = Yii::$app->request->get('dis'); $map = ['maker_disp' => $display]; $query = MirMaker::find()->where($map); $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(['maker_id' => $this->maker_id, 'maker_date' => $this->maker_date, 'maker_disp' => $this->maker_disp]); $query->andFilterWhere(['like', 'maker_name', $this->maker_name])->andFilterWhere(['like', 'maker_name_e', $this->maker_name_e])->andFilterWhere(['like', 'maker_info', $this->maker_info])->andFilterWhere(['like', 'maker_info_e', $this->maker_info_e])->andFilterWhere(['like', 'maker_character', $this->maker_character])->andFilterWhere(['like', 'maker_character_e', $this->maker_character_e])->andFilterWhere(['like', 'maker_place', $this->maker_place])->andFilterWhere(['like', 'maker_place_e', $this->maker_place_e])->andFilterWhere(['like', 'maker_proclass', $this->maker_proclass])->andFilterWhere(['like', 'maker_class', $this->maker_class])->andFilterWhere(['like', 'maker_contact', $this->maker_contact])->andFilterWhere(['like', 'maker_contact_e', $this->maker_contact_e]); return $dataProvider; }
/** * Finds the MirMaker model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return MirMaker the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = MirMaker::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * 搜索某一个生产厂商生产的产品 * @author wonguohui * @Date 2016-01-10T01:22:32+0800 * @param $name 厂商名称 * @return array */ public function searchMaker($name) { $maker = \backend\models\MirMaker::find()->select(['maker_id'])->where(['like', 'maker_name', $name])->asArray()->all(); return ArrayHelper::getColumn($maker, 'maker_id'); }