/** * get highest idVisit to delete rows from * @return string */ private function getDeleteIdVisitOffset() { $logVisit = Common::prefixTable("log_visit"); // get max idvisit $maxIdVisit = Db::fetchOne("SELECT MAX(idvisit) FROM {$logVisit}"); if (empty($maxIdVisit)) { return false; } // select highest idvisit to delete from $dateStart = Date::factory("today")->subDay($this->deleteLogsOlderThan); $sql = "SELECT idvisit\n\t\t FROM {$logVisit}\n\t\t WHERE '" . $dateStart->toString('Y-m-d H:i:s') . "' > visit_last_action_time\n\t\t AND idvisit <= ?\n\t\t AND idvisit > ?\n\t\t ORDER BY idvisit DESC\n\t\t LIMIT 1"; return Db::segmentedFetchFirst($sql, $maxIdVisit, 0, -self::$selectSegmentSize); }
public function getDeleteIdVisitOffset($date, $maxIdVisit, $segmentSize) { $sql = 'SELECT idvisit ' . 'FROM ' . $this->table . ' ' . "WHERE '" . $date . "' > visit_last_action_time " . ' AND idvisit <= ? ' . ' AND idvisit > ? ' . 'ORDER BY idvisit DESC ' . 'LIMIT 1'; return Db::segmentedFetchFirst($sql, $maxIdVisit, 0, $segmentSize); }