Answer the question
In order to leave comments, you need to log in
How to organize range search in yii2?
Hello. There is yii2, there is a table column "price". Tell me how to organize a search by price range, for example: search from 100 to 200? Maybe there is a module, or is there an article on the implementation of this? I searched but didn't find anything useful. I would appreciate any information on this matter.
Answer the question
In order to leave comments, you need to log in
Maxim Fedorov gave a working example, I'll add it as an option:
$small = 100;
$big = 200;
MyModel::find()
->andWhere(['>','attribute', $small])
->andWhere(['<','attribute', $big])
->all();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question