config = $config; $this->entityManager = $entityManager; } protected $cleanupRemindersPeriod = '15 days'; public function process() { $period = '-' . $this->config->get('cleanupRemindersPeriod', $this->cleanupRemindersPeriod); $datetime = new \DateTime(); $datetime->modify($period); $pdo = $this->entityManager->getPDO(); $query = "DELETE FROM `reminder` WHERE DATE(remind_at) < " . $pdo->quote($datetime->format('Y-m-d')); $sth = $pdo->prepare($query); $sth->execute(); } }