/** * 時間段查詢條件獲取 * @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; }