db = $db; } /** * @param SubscriptionCycleCacheData[] $data */ public function createCacheEntries(array $data): void { if (!empty($data)) { $insert = $this->db->insert() ->into(self::TABLE_NAME); foreach ($data as $entry) { $insert->addRow() ->cols( [ 'subscription_article_id' => $entry->getSubscriptionArticleId(), 'start_date' => $entry->getStartDate()->format('Y-m-d'), 'cycles_count' => $entry->getCyclesCount(), 'calculation_base_date' => $entry->getCalculationBaseDate()->format('Y-m-d'), 'start_month_price_factor' => $entry->getStartMonthPriceFactor(), ] ); } $insertSql = $insert->getStatement(); $values = $insert->getBindValues(); $this->db->perform($insertSql, $values); } } public function emptyCache(): void { $sql = 'TRUNCATE `subscription_cycle_cache`'; $this->db->perform($sql); } }