CBitrixCloudOption::_update_db: Bitrix method

      
<?php 
//  CBitrixCloudOption :: _update_db()
//  /dist/bitrix/modules/bitrixcloud/classes/general/option.php:104

    
private function _update_db($value)
    {
        global 
$DB;
        if (!
is_array($value))
            
$value = array();

        
reset($value);
        
$rs $DB->Query("
            select ID, SORT, PARAM_KEY, PARAM_VALUE
            from b_bitrixcloud_option
            where NAME = '"
.$DB->ForSQL($this->name)."'
            order by ID
        "
);

        
$sort 0;
        while (list(
$key$val) = each($value))
        {
            if (
$db_row $rs->fetch())
            {
                if (
                    
"".$db_row["PARAM_VALUE"]."" !== "".$val.""
                    
|| "".$db_row["PARAM_KEY"]."" !== "".$key.""
                    
|| "".$db_row["SORT"]."" !== "".$sort.""
                
)
                {
                    
$DB->Query("
                        UPDATE b_bitrixcloud_option SET
                            PARAM_KEY = '"
.$DB->ForSql($key50)."'
                            ,PARAM_VALUE = '"
.$DB->ForSql($val200)."'
                            ,SORT = "
.$sort."
                        WHERE ID = "
.$db_row["ID"]."
                    "
);
                }
            }
            else
            {
                
$DB->Add("b_bitrixcloud_option", array(
                    
"NAME" => $this->name,
                    
"SORT" => (string)$sort,
                    
"PARAM_KEY" => $key,
                    
"PARAM_VALUE" => $val,
                ));
            }
            
$sort++;
        }

        if (
$db_row $rs->fetch())
        {
            
$DB->Query("
                DELETE FROM b_bitrixcloud_option
                WHERE NAME = '"
.$DB->ForSql($this->name50)."'
                AND ID >= "
.$db_row["ID"]."
            "
);
        }
    }