- Модуль: seo
- Путь к файлу: ~/bitrix/modules/seo/classes/general/seo_keywords.php
- Класс: CSeoKeywords
- Вызов: CSeoKeywords::Update
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))."'";
}
}
$condition = $strUpdateBy == 'ID' ? 'WHERE ID=''.$ID.''' : 'WHERE URL=''.$URL.''';
if($siteId = $DB->ForSql($arFields['SITE_ID']))
$condition .= ' AND SITE_ID=''.$siteId.''';
$cnt = $DB->Update('b_seo_keywords', $arUpdate, $condition);
if ($cnt <= 0 && $strUpdateBy == 'URL')
{
$arUpdate['URL'] = "'".$URL."'";
$cnt = intval(($DB->Insert('b_seo_keywords', $arUpdate)) > 0);
}
return $cnt;
}