private function deleteNewEntries($tableName, Gpf_DateTime $fromDate) { $updateBuilder = new Gpf_SqlBuilder_UpdateBuilder(); for ($i = $fromDate->getDay(); $i<=31; $i++) { $updateBuilder->set->add("raw_$i", 0); $updateBuilder->set->add("unique_$i", 0); if (strstr($tableName, 'click')) { $updateBuilder->set->add("declined_$i", 0); } } $updateBuilder->from->add($tableName); $updateBuilder->where->add('month', '=', $fromDate->getMonthStart()->toDate()); $updateBuilder->execute(); $delete = new Gpf_SqlBuilder_DeleteBuilder(); $delete->from->add($tableName); $delete->where->add('month', '>', $fromDate->toDate()); $delete->execute(); }
/** * * @return Gpf_DateTime_Range */ public function getDateRange(Gpf_DateTime $now = null) { if($now === null) { $now = new Gpf_DateTime(); } if ($this->getDate() == Pap_Features_PerformanceRewards_Rule::DATE_ALL_TIME || $this->getDate() == Pap_Features_PerformanceRewards_Rule::DATE_ALL_UNPAID_COMMISSIONS) { $range = new Gpf_DateTime_Range(); return $range; } if ($this->getDate() == Pap_Features_PerformanceRewards_Rule::DATE_SINCE_DAY_OF_LAST_MONTH) { $from = $now->getMonthStart(); $from->addMonth(-1); $from->addDay($this->getSince() - 1); $to = $now->getMonthStart(); $to->addDay(-1); return new Gpf_DateTime_Range($from, $to); } $filter = new Gpf_SqlBuilder_Filter(); $result = $filter->decodeDatePreset($this->getDate()); return new Gpf_DateTime_Range(new Gpf_DateTime($result['dateFrom']), new Gpf_DateTime($result['dateTo'])); }