You are here

function currency_api_save in Currency 7

Same name and namespace in other branches
  1. 5 currency_api/currency_api.module \currency_api_save()
  2. 6 currency_api/currency_api.module \currency_api_save()

Cache rate for from and to countries delete outdated record, if exists.

Parameters

string $currency_from:

string $currency_to:

decimal $rate:

1 call to currency_api_save()
currency_api_convert in currency_api/currency_api.module
Currency exchange rate API function.

File

currency_api/currency_api.module, line 380
This module provides an API for currency conversion.

Code

function currency_api_save($currency_from, $currency_to, $rate) {

  // Insert or update record.
  db_merge('currencyapi')
    ->key(array(
    'currency_from' => $currency_from,
    'currency_to' => $currency_to,
  ))
    ->fields(array(
    'rate' => $rate,
    'timestamp' => REQUEST_TIME,
  ))
    ->execute();
}