CakePHP find condition for a query between two dates

前端 未结 6 1136
谎友^
谎友^ 2020-12-30 08:59

I have a start and an end date in my database and a $date variable from a form field. I am now trying to query all the rows where $date is either = start/end date in the db,

6条回答
  •  时光说笑
    2020-12-30 09:58

    $data=$this->post->find('all')->where([ 'id'=>$id,
    'price between'=>$price1,'and'=>$price2])->toArray();
    

    This query works as following:

    select * from post where id=$id and price between $price1 and $price2;
    

    " -- 'price between'=>$price1 --" become "price between $price1"

提交回复
热议问题