/**
 * 时间段查询条件获取
 * @param string $star  获取开始时间的字段名
 * @param string $end   获取结束时间的字段名 
 * @param string $zd    数据库where条件的字段名
 */
function where_time($start='start_time',$end='end_time',$zd='create_time'){
    $start_time=I('get.'.$start,'','filter_str');
    $end_time=I('get.'.$end,'','filter_str');
    $map = array();
    if(!empty($start_time)){
        $start_time=strtotime($start_time);
        $map[$zd] = array('gt',$start_time);
    }
    
    if(!empty($end_time)){
        $end_time=strtotime($end_time);
        if(empty($map[$zd])){
            $map[$zd] = array('lt',$end_time);
        }else{
            $map[$zd]=array($map[$zd],array('lt',$end_time));
        }
    }
    return $map;
}

 

 

相关文章:

  • 2022-12-23
  • 2021-05-31
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-04
  • 2021-07-17
  • 2021-10-15
  • 2021-09-19
  • 2022-12-23
  • 2021-05-21
相关资源
相似解决方案