CAdvBanner :: GetCountryArray: Bitrix method

      
<?php 
//  CAdvBanner :: GetCountryArray()
//  /dist/bitrix/modules/advertising/classes/general/advertising.php:1624

    
public static function GetCountryArray($BANNER_ID$WHAT "COUNTRY")
    {
        
$err_mess = (CAdvBanner_all::err_mess())."<br>Function: GetCountryArray<br>Line: ";
        global 
$DB;
        
$BANNER_ID intval($BANNER_ID);
        if (
$BANNER_ID<=0)
            return 
false;
        
$arrRes = array();
        if(!
is_array($WHAT))
        {
            if(
$WHAT === "CITY")
                
$arSelect = array("COUNTRY_ID""REGION""CITY_ID");
            elseif(
$WHAT === "REGION")
                
$arSelect = array("COUNTRY_ID""REGION");
            else
                
$arSelect = array("COUNTRY_ID");
        }
        else
        {
            
$arSelect = array();
            foreach(
$WHAT as $FIELD)
            {
                if(
$FIELD === "CITY_ID")
                    
$arSelect[$FIELD] = $FIELD;
                elseif(
$FIELD === "REGION")
                    
$arSelect[$FIELD] = $FIELD;
                elseif(
$FIELD === "COUNTRY_ID")
                    
$arSelect[$FIELD] = $FIELD;
            }
            if(
count($arSelect) <= 0)
                
$arSelect = array("COUNTRY_ID");
        }

        
$strSql "
            SELECT DISTINCT
                "
.implode(", "$arSelect)."
            FROM
                b_adv_banner_2_country
            WHERE
                BANNER_ID = 
$BANNER_ID
            ORDER BY
                "
.implode(", "$arSelect)."
            "
;
        
$rs $DB->Query($strSqlfalse$err_mess.__LINE__);
        while(
$ar $rs->Fetch())
        {
            if(
$WHAT === "COUNTRY")
                
$arrRes[] = $ar["COUNTRY_ID"];
            else
                
$arrRes[] = $ar;
        }
        return 
$arrRes;
    }