예제 #1
0
 public static function Format($currency, $amount, $precision = 2)
 {
     try {
         $sExchangeRate = ExchangeRate::CreateFromQuery("SELECT * FROM exchange_rates WHERE `Code` = :Code", array(":Code" => $currency), 30, true);
     } catch (NotFoundException $e) {
         throw new CurrencyFormattingException("The specified currency is not a valid currency code.");
     }
     if ($sExchangeRate->sSymbol == "") {
         return "{$sExchangeRate->sCurrencyCode} " . number_format($amount, $precision);
     } else {
         return "{$sExchangeRate->sSymbol}" . number_format($amount, $precision);
     }
 }
예제 #2
0
 public static function Update($code, $to)
 {
     $from = 1 / $to;
     try {
         $sRate = ExchangeRate::CreateFromQuery("SELECT * FROM exchange_rates WHERE `Code` = :Code", array(":Code" => $code), 0, true);
     } catch (NotFoundException $e) {
         $sRate = new ExchangeRate(0);
         $sRate->uCurrencyCode = $code;
     }
     $sRate->uToRate = $to;
     $sRate->uFromRate = $from;
     $sRate->uUpdateDate = time();
     $sRate->InsertIntoDatabase();
 }