Documentation

GetList

CDBResult
CCurrencyRates::GetList(
 string &by, 
 string &order, 
 array arFilter = Array()
);

This method returns the sorted list of exchange rates, satisfying the arFilter filter, sorted by "by" filter in the "order" sorting direction. Static method.

Parameters

ParameterDescription
by Variable containing the name of the sorting field. The following values are possible:
  • date - date of the rate (default);
  • curr - currency field;
  • rate - rate field.
order Variable containing sort direction. The following values are possible:
  • asc - ascending (default);
  • desc - descending.
arFilter Record filter is an associative array in which keys are the names of filtered fields and values are the filter conditions. Optional parameter.

The following filter fields are possible:
  • CURRENCY - the currency ID;
  • DATE_RATE - the date of the exchange rate (records containing dates later or equal to the specified one are selected);
  • !DATE_RATE - the date of the rate (records containing earlier dates than the specified one are selected).

Return Values

CDBResult-class object, containing the records with the following keys.

Key Description
ID The exchange rate ID.
CURRENCY The currency ID.
DATE_RATE The date for which the rate is set.
RATE_CNT The number of currency units used to define the rate of exchange (for example, if CYP 10 equal to USD 21.58, 10 is the number of currency units).
RATE The default rate of exchange. (One of currencies within a site must equal to 1. Such currency is called a base currency. Other currencies are defined relative to the base currency.)

Example


<?
// Display all USD rates, sorted by date
$arFilter = array(
    "CURRENCY" => "USD"
    );
$by = "date";
$order = "desc";

$db_rate = CCurrencyRates::GetList($by, $order, $arFilter);
while($ar_rate = $db_rate->Fetch())
{
    echo $ar_rate["RATE"]."<br>";
}
?>
© «Bitrix24», 2001-2024
Up