public function save(array $rates)
    {
        $this->connection->beginTransaction();

        try {

            /**
             * @var RateInterface $rate
             */
            foreach ($rates as $rate) {

                if ($this->has($rate->getSourceName(), $rate->getCurrencyCode(), $rate->getDate(), $rate->getRateType())) {

                    $this->connection->executeQuery(sprintf('UPDATE %s SET rate_value = :rate_value, modified_at = :modified_at WHERE source_name = :source_name AND currency_code = :currency_code AND rate_date = :rate_date AND rate_type = :rate_type;', $this->tableName), [
                        'rate_value'    => (float)$rate->getValue(),
                        'source_name'   => $rate->getSourceName(),
                        'currency_code' => $rate->getCurrencyCode(),
                        'rate_date'     => $rate->getDate()->format('Y-m-d'),
                        'rate_type'     => $rate->getRateType(),
                        'modified_at'   => date('Y-m-d H:i:s'),
                    ]);

                    continue;
                }

                $this->connection->executeQuery(sprintf('INSERT INTO %s (source_name, rate_value, currency_code, rate_type, rate_date, base_currency_code, created_at, modified_at) VALUES (:source_name, :rate_value, :currency_code, :rate_type, :rate_date, :base_currency_code, :created_at, :modified_at);', $this->tableName), [
                    'source_name'        => $rate->getSourceName(),
                    'rate_value'         => (float)$rate->getValue(),
                    'currency_code'      => $rate->getCurrencyCode(),
                    'rate_type'          => $rate->getRateType(),
                    'rate_date'          => $rate->getDate()->format('Y-m-d'),
                    'base_currency_code' => $rate->getBaseCurrencyCode(),
                    'created_at'         => date('Y-m-d H:i:s'),
                    'modified_at'        => date('Y-m-d H:i:s'),
                ]);
            }

            $this->connection->commit();
            $this->identityMap = [];
        } catch (\Exception $e) {
            $this->connection->rollBack();
            throw new ExchangeRateException('Unable to save rates.', 0, $e);
        }
    }
public function save(array $rates)
    {
        $this->connection->beginTransaction();

        try {

            /**
             * @var RateInterface $rate
             */
            foreach ($rates as $rate) {

                if ($this->has($rate->getSourceName(), $rate->getCurrencyCode(), $rate->getDate(), $rate->getRateType())) {

                    $this->connection->executeQuery(sprintf('UPDATE %s SET rate_value = :rate_value, modified_at = :modified_at WHERE source_name = :source_name AND currency_code = :currency_code AND rate_date = :rate_date AND rate_type = :rate_type;', $this->tableName), [
                        'rate_value'    => (float)$rate->getValue(),
                        'source_name'   => $rate->getSourceName(),
                        'currency_code' => $rate->getCurrencyCode(),
                        'rate_date'     => $rate->getDate()->format('Y-m-d'),
                        'rate_type'     => $rate->getRateType(),
                        'modified_at'   => date('Y-m-d H:i:s'),
                    ]);

                    continue;
                }

                $this->connection->executeQuery(sprintf('INSERT INTO %s (source_name, rate_value, currency_code, rate_type, rate_date, base_currency_code, created_at, modified_at) VALUES (:source_name, :rate_value, :currency_code, :rate_type, :rate_date, :base_currency_code, :created_at, :modified_at);', $this->tableName), [
                    'source_name'        => $rate->getSourceName(),
                    'rate_value'         => (float)$rate->getValue(),
                    'currency_code'      => $rate->getCurrencyCode(),
                    'rate_type'          => $rate->getRateType(),
                    'rate_date'          => $rate->getDate()->format('Y-m-d'),
                    'base_currency_code' => $rate->getBaseCurrencyCode(),
                    'created_at'         => date('Y-m-d H:i:s'),
                    'modified_at'        => date('Y-m-d H:i:s'),
                ]);
            }

            $this->connection->commit();
            $this->identityMap = [];
        } catch (\Exception $e) {
            $this->connection->rollBack();
            throw new ExchangeRateException('Unable to save rates.', 0, $e);
        }
    }
{@inheritdoc}