public function actionBatchBind() { $ids = Yii::$app->request->post('ids'); $rows = AccessDeviceInfo::find()->where(['id' => explode(',', $ids)])->select(["ip" => 'learnIp', 'mac' => 'learnMac', 'id'])->asArray()->all(); foreach ($rows as $row) { $this->bind($row["ip"], $row["mac"], $row['id']); } $this->redirect(Yii::$app->request->referrer); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = AccessDeviceInfo::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(['id' => $this->id, 'deviceId' => $this->deviceId, 'ifIndex' => $this->ifIndex, 'vlanId' => $this->vlanId, 'status' => $this->status, 'update_time' => $this->update_time]); $query->andFilterWhere(['like', 'deviceIp', $this->deviceIp])->andFilterWhere(['like', 'ifDesc', $this->ifDesc])->andFilterWhere(['like', 'learnIp', $this->learnIp])->andFilterWhere(['like', 'learnMac', $this->learnMac]); return $dataProvider; }