Answer the question
In order to leave comments, you need to log in
Is it possible to include an array in where in Yii2?
I'm doing a search, in the search you can select many values in the same category. There may be many.
$modelExchangeSearchForm = new ExchangeSearchForm();
if ($modelExchangeSearchForm->load(Yii::$app->request->get()) && $modelExchangeSearchForm->validate()) {
$orders = Order::find()
->filterWhere([
'country_id' => $modelExchangeSearchForm->country_id,
'club_id' => $modelExchangeSearchForm->club_id,
'apartment_type_id' => $modelExchangeSearchForm->apartment_type_id,
'season_id' => $modelExchangeSearchForm->season_id,
'type' => $modelExchangeSearchForm->order_type,
'is_membership' => $modelExchangeSearchForm->is_membership,
'is_expertize' => $modelExchangeSearchForm->is_expertize,
'is_penalty' => $modelExchangeSearchForm->is_penalty,
'is_priced' => $modelExchangeSearchForm->is_priced,
'bonus_weeks' => $modelExchangeSearchForm->bonus_weeks,
])
->andFilterWhere(['>=', 'priced_value', $modelExchangeSearchForm->price_from])
->andFilterWhere(['>=', 'priced_value', $modelExchangeSearchForm->price_from]);
Answer the question
In order to leave comments, you need to log in
It's not clear what you mean, but it looks like this:
$orders = Order::find();
foreach($some_array as $key=>$value){
$orders->andFilterWhere([$key=>$value]);
}
$orders->andFilterWhere(['>=', 'priced_value', $modelExchangeSearchForm->price_from]);
$orders->andFilterWhere(['>=', 'priced_value', $modelExchangeSearchForm->price_from]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question