Yii2模型查询之间的搜索 [英] Yii2 model search between query
本文介绍了Yii2模型查询之间的搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在yii2模型search()中隐含以下mysql查询
I Want to impliment below mysql query in yii2 model search()
SELECT * FROM `parking_availability` WHERE ('09:00' BETWEEN `time_start` AND `time_end` ) AND
( '11:00' BETWEEN `time_start` AND `time_end` )
我已经这样申请
$query->andFilterWhere([$this->arrivaltime,'between','time_star', 'time_end'])
->andFilterWhere([$this->departuretime,'between','time_star', 'time_end']);
但是其显示错误运算符"09:00"需要两个操作数.
请帮助我,谢谢
推荐答案
您尝试的方向正确,但是参数顺序错误.第一个必须是'between'
运算符:
You were in the right direction in your attempts, but you got the parameters in the wrong order. The first has to be the 'between'
operator:
$query->andFilterWhere(['between', $this->arrivaltime, 'time_start', 'time_end'])
->andFilterWhere(['between', $this->departuretime, 'time_start', 'time_end']);
这篇关于Yii2模型查询之间的搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文