/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = UserText::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, 'id_user' => $this->id_user, 'id_device' => $this->id_device]); $query->andFilterWhere(['like', 'txt1', $this->txt1])->andFilterWhere(['like', 'txt2', $this->txt2]); return $dataProvider; }
public function getMyMkey() { $ut = UserText::find()->where(['id_user' => Yii::$app->user->identity->id])->andFilterWhere(['id_device' => $this->id_dev])->andFilterWhere(['txt1' => $this->mkey])->one(); // проверека должна быть!!! return $ut->txt2; }
public function getMyNameField() { $ut = UserText::find()->where(['id_user' => Yii::$app->user->identity->id])->andFilterWhere(['id_device' => $this->id_device])->andFilterWhere(['txt1' => $this->templ])->one(); return $ut->txt2; }
/** * Finds the UserText model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return UserText the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = UserText::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }