一 查询数据
1 获取上次更新时间
可以保存在文本里。
public function getLastUpdate(){
$sLastUpdate = $this->oFileServer->tryFileGetContents($this->getLastUpdatePath());
$this->aLastUpdate = json_decode($sLastUpdate,true);
}
2 获取最新系统时间作为更新时间
select to_char(sysdate,'YYYY-MM-DD HH24:MI:SS') as time from dual
3 处理日期间隔
public function getDateGap($sStartDate,$sEndDate,$type='delta'){
$res = [];
$iStartStamp = strtotime($sStartDate);
$iEndStamp = strtotime($sEndDate);
if ($type == 'full') array_push($res,['gt'=>'','lt'=>date('Y-m-d H:i:s',$iStartStamp)]);
$aGap = [['gap'=>'7','limit'=>2],['gap'=>'3','limit'=>2],['gap'=>'1','limit'=>0]];//代表按7天的间隔返回,直至近2天后按下一个数组配置再返回后面的间隔
do{
$iTamp = $iStartStamp + $this->dealGap($iEndStamp,$iStartStamp,$aGap);
array_push($res,['gt'=>date('Y-m-d H:i:s',$iStartStamp),'lt'=>date('Y-m-d H:i:s',$iTamp)]);
$iStartStamp = $iTamp;
}while($iStartStamp <= $iEndStamp);
return $res;
}
public function dealGap($iEndStamp, $iStartStamp, $aGaps){
$iDayGap = 60 * 60 * 24;
$aGap = array_shift($aGaps);
if(floor(($iEndStamp - $iStartStamp)/($iDayGap*$aGap['gap']))<=$aGap['limit']){
if (empty($aGaps)){
return $iEndStamp