CakePHP Search between 2 Date Records

后端 未结 6 1910
再見小時候
再見小時候 2020-12-11 10:20

I am building a small Web App that lets users reserve Office Rooms and Equipment. For the Reservation they enter a Start and an End Date.

When a user tries to find o

6条回答
  •  被撕碎了的回忆
    2020-12-11 11:03

    Here is CakePHP BETWEEN query example.

    I'm defining my arrays as variables, and then using those variables in my CakePHP find function call:

    // just return these two fields
    $fields = array('uri', 'page_views');
    
    // use this "between" range
    $conditions = array('Event.date BETWEEN ? and ?' => array($start_date, $end_date));
    
    // run the "select between" query
    $results = $this->Event->find('all', 
             array('fields'=>$fields, 
                   'conditions'=>$conditions));
    

    Ref from

提交回复
热议问题