CakePHP find condition for a query between two dates

前端 未结 6 1162
谎友^
谎友^ 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 10:03

    This is more efficient and understandable IN BETWEEN query in cakephp 2.x

    $testing_log_device_site_name = $testingLogData['TestingLogDevice']['Siteid'];
    
    $conditions = array('TestingLogDevice.dateee BETWEEN ? and ?' => array($start_date, $end_date));
    
    $results = $this->TestingLogDevice->find('all', 
        array(
             'fields'=>array('dateee','timeee','Siteid'), 
             'conditions'=>array($conditions, 'TestingLogDevice.Siteid'=>$testing_log_device_site_name)
        )
    );
    pr($results);
    

提交回复
热议问题