Answer the question
In order to leave comments, you need to log in
How to make a between query in Yii2?
Hello. It is not possible to correctly compose a between query using Yii2.
At the moment I have this option:
$ips = Ip::find()->where("'$userIp' between ip_start and ip_end")->one();
$model = ModelName::find()->where(['between', 'date', "2015-06-21", "2015-06-27" ])->all();
Answer the question
In order to leave comments, you need to log in
$ips = Ip::find()
->where(['>', 'ip_start', $userIp])
->andWhere(['<', 'ip_end', $userIp])
->one();
Quoting the docs :
between: operand 1 should be the column name, and operand 2 and 3 should be the starting and ending values of the range that the column is in. For example, ['between', 'id', 1, 10] will generate id BETWEEN 1 AND 10
https://github.com/yiisoft/yii2/blob/master/docs/g...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question