/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = UserText::find(); $query->andWhere(['isStart' => $this->isStart, 'isEnd' => $this->isEnd]); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['ut_id' => $this->ut_id, 'p_id' => $this->p_id, 'b_id' => $this->b_id, 'l_id' => $this->l_id, 't_id' => $this->t_id]); return $dataProvider; }
public static function getText($user = null, $bank = null, $language = null, $isStart = true) { $query = UserText::find()->andWhere(['OR', 'p_id=0', 'p_id=' . $user])->andWhere(['OR', 'b_id=0', 'b_id="' . $bank . '"'])->andWhere(['OR', 'l_id=0', 'l_id=' . ($language == 'default' ? '0' : $language)]); if (!$isStart) { $query->andWhere(['isEnd' => 1]); } else { $query->andWhere(['isStart' => 1]); } $query->orderBy(['p_id' => SORT_DESC, 'b_id' => SORT_DESC, 'l_id' => SORT_DESC]); $text = $query->one(); return $text; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = UserText::find(); $query->andWhere(['isStart' => $this->isStart, 'isEnd' => $this->isEnd]); $pageSize = Yii::$app->session->get('pageSize', Yii::$app->params['defaultPageSize']); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => $pageSize]]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['ut_id' => $this->ut_id, 'p_id' => $this->p_id, 'b_id' => $this->b_id, 'l_id' => $this->l_id, 't_id' => $this->t_id]); return $dataProvider; }
public static function getText($user = null, $bank = null, $language = null, $isStart = true) { $query = UserText::find()->where(['p_id' => $user, 'b_id' => $bank, 'l_id' => $language == 'default' || $language === null ? '0' : $language])->orWhere(['p_id' => 0, 'b_id' => 0, 'l_id' => $language == 'default' || $language === null ? '0' : $language]); if (!$isStart) { $query->andWhere(['isEnd' => 1]); } else { $query->andWhere(['isStart' => 1]); } $query->orderBy(['p_id' => SORT_DESC, 'b_id' => SORT_DESC, 'l_id' => SORT_DESC]); $text = $query->one(); return $text; }
/** * 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; }