public static function Update($arFields) { global $APPLICATION, $DB; if (!CSeoKeywords::CheckFields('UPDATE', $arFields)) { return false; } $strUpdateBy = isset($arFields['ID']) ? 'ID' : 'URL'; if ($strUpdateBy == 'ID') { $ID = $arFields['ID']; unset($arFields['ID']); } else { $URL = $DB->ForSql($arFields['URL']); unset($arFields['URL']); } $arAllFields = array('ID', 'URL', 'SITE_ID', 'KEYWORDS'); $arUpdate = array(); foreach ($arFields as $key => $value) { if (in_array($key, $arAllFields)) { $arUpdate[$key] = "'" . ($key == 'SITE_ID' ? $DB->ForSql($value, 2) : $DB->ForSql($value)) . "'"; } } $cnt = $DB->Update('b_seo_keywords', $arUpdate, $strUpdateBy == 'ID' ? 'WHERE ID=\'' . $ID . '\'' : 'WHERE URL=\'' . $URL . '\''); if ($cnt <= 0 && $strUpdateBy == 'URL') { $arUpdate['URL'] = "'" . $URL . "'"; $cnt = intval($DB->Insert('b_seo_keywords', $arUpdate) > 0); } return $cnt; }