本文整理汇总了PHP中CCurrencyRates::getConvertFactorEx方法的典型用法代码示例。如果您正苦于以下问题:PHP CCurrencyRates::getConvertFactorEx方法的具体用法?PHP CCurrencyRates::getConvertFactorEx怎么用?PHP CCurrencyRates::getConvertFactorEx使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCurrencyRates
的用法示例。
在下文中一共展示了CCurrencyRates::getConvertFactorEx方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateBaseRates
/**
* Update current currencies rates to base currency.
*
* @param string $updateCurrency Update currency id.
* @return void
* @throws Main\ArgumentException
* @throws \Exception
*/
public static function updateBaseRates($updateCurrency = '')
{
$currency = (string) static::getBaseCurrency();
if ($currency === '') {
return;
}
$currencyIterator = CurrencyTable::getList(array('select' => array('CURRENCY', 'CURRENT_BASE_RATE'), 'filter' => $updateCurrency == '' ? array() : array('=CURRENCY' => $updateCurrency)));
while ($existCurrency = $currencyIterator->fetch()) {
$baseRate = $existCurrency['CURRENCY'] != $currency ? \CCurrencyRates::getConvertFactorEx($existCurrency['CURRENCY'], $currency) : 1;
$updateResult = CurrencyTable::update($existCurrency['CURRENCY'], array('CURRENT_BASE_RATE' => $baseRate));
if ($updateResult->isSuccess()) {
$event = new Main\Event('currency', self::EVENT_ON_AFTER_UPDATE_BASE_RATE, array('OLD_BASE_RATE' => (double) $existCurrency['CURRENT_BASE_RATE'], 'CURRENT_BASE_RATE' => $baseRate, 'BASE_CURRENCY' => $currency, 'CURRENCY' => $existCurrency['CURRENCY']));
$event->send();
}
unset($updateResult);
unset($baseRate);
}
unset($existCurrency, $currencyIterator);
}