问题
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` )
I have applied like this
$query->andFilterWhere([$this->arrivaltime,'between','time_star', 'time_end'])
->andFilterWhere([$this->departuretime,'between','time_star', 'time_end']);
But its showing error Operator '09:00' requires two operands.
Please help me , Thanks
回答1:
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']);
来源:https://stackoverflow.com/questions/43318711/yii2-model-search-between-query