Bitrix Site Manager

CCountry::GetList

CDBResult
CCountry::GetList(
 string &by = "s_name",
 string &order = "desc",
 array filter = array(),
 bool &is_filtered
)

The method GetList returns a list of countries defined in the Statistics module. The list of countries is loaded when re-indexing the IP database in the Statistics module settings.

Parameters

Parameter Description
by Sorting field. The following values are possible:
  • s_id - two-character country identifier;
  • s_short_name - three-character country identifier;
  • s_name - name of the country;
  • s_sessions - total number of sessions for this country;
  • s_new_guests - total number of new visitors for this country;
  • s_hits - total number of hits for this country;
  • s_events - total number of events for this country.
order Sort order; the following values are possible:
  • asc - ascending;
  • desc - descending.
filter Array used to filter the output. The following keys are possible:
  • ID* - two-character country identifier;
  • ID_EXACT_MATCH - if "N", entry in the ID is sufficient (loose match);
  • SHORT_NAME* - three-character country identifier;
  • SHORT_NAME_EXACT_MATCH - if "Y", SHORT_NAME's must match exactly (strict match);
  • NAME* - name of the country;
  • NAME_EXACT_MATCH - if "Y", NAME_EXACT_MATCH's must match exactly (strict match);
  • SESSIONS1 - minimum value of the range for the "number of sessions" field;
  • SESSIONS2 - maximum value of the range for the "number of sessions" field;
  • NEW_GUESTS1 - minimum value of the range for the "number of new visitors" field;
  • NEW_GUESTS2 - maximum value of the range for the "number of new visitors" field;
  • HITS1 - minimum value of the range for the "number of hits" field;
  • HITS2 - maximum value of the range for the "number of hits" field;
  • EVENTS1 - minimum value of the range for the "number of events" field;
  • EVENTS2 - maximum value of the range for the "number of events" field.

    * - complex logic allowed.
is_filtered If this flag contains "true" on return, the resulting list is filtered.

Structure of the returned record

Array
(
    [ID] => two-character country identifier
    [SHORT_NAME] => three-character country identifier
    [NAME] => name of the country
    [SESSIONS] => total number of sessions
    [NEW_GUESTS] => total number of new visitors
    [HITS] => total number of hits
    [C_EVENTS] => total number of events
    [REFERENCE_ID] => the REFERENCE_ID parameter for use with SelectBox and SelectBoxM
    [REFERENCE] => the REFERENCE parameter for use with SelectBox and SelectBoxM
)

See Also

Example



<?
// select countries with at least 100 sessions
$arFilter = array(
    "SESSIONS1" => 100
    );

// obtain the list
$rs = CCountry::GetList(
    ($by = "s_name"), 
    ($order = "desc"), 
    $arFilter, 
    $is_filtered
    );

// print records
while ($ar = $rs->Fetch())
{
    echo "<pre>"; print_r($ar); echo "</pre>";    
}
?>


<?
// single selection drop-down liat
echo SelectBox("COUNTRY_ID", CCountry::GetList(), "", intval($COUNTRY_ID));

// multiple selection list with 20 visible items
echo SelectBoxM("arCOUNTRY_ID[]", CCountry::GetList(), $arCOUNTRY_ID, "", false, 20);
?>