_db->select(); $select->from($this->_getPair(), ['id', 'expiredOn']); if (!($expiredOn = $this->getFilter('expiredOn'))) { throw new Exception('expiredOn dates are note defined'); }; $select->where('`l`.`expiredOn` IN(?)', $expiredOn); $select->where('`l`.`status` = ?', Entity::STATUS_ACTIVE); $select->order('l.expiredOn DESC'); return $select; } /** * @param $gracePeriod * @return int number of expired licenses * @throws \Zend_Db_Adapter_Exception */ public function disableExpired($gracePeriod) { $gracePeriod = (int) $gracePeriod; $date = date('Y-m-d', strtotime('-' . $gracePeriod . ' days')); $sql = ' UPDATE ' . Qs_Db::getPairExpr('License', 'l') . ' ' . 'SET `l`.`status` = ' . $this->_db->quote(Entity::STATUS_EXPIRED) . ' ' . 'WHERE `l`.`status` = ' . $this->_db->quote(Entity::STATUS_ACTIVE) . ' ' . 'AND `l`.`expiredOn` <= ' . $this->_db->quote($date) . ' '; return $this->_db->exec($sql); } }