本文整理汇总了PHP中CCatalogDiscount::CheckFields方法的典型用法代码示例。如果您正苦于以下问题:PHP CCatalogDiscount::CheckFields方法的具体用法?PHP CCatalogDiscount::CheckFields怎么用?PHP CCatalogDiscount::CheckFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCatalogDiscount
的用法示例。
在下文中一共展示了CCatalogDiscount::CheckFields方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _Update
public function _Update($ID, &$arFields)
{
global $DB;
global $stackCacheManager;
global $APPLICATION;
$ID = intval($ID);
if ($ID <= 0)
return false;
if (!CCatalogDiscount::CheckFields("UPDATE", $arFields, $ID))
return false;
if (isset($arFields['VALUE']) != isset($arFields['VALUE_TYPE']))
{
$rsDiscounts = CCatalogDiscount::GetList(array(),array('ID' => $ID), false, array('nTopCount' => 1), array('ID', 'VALUE', 'VALUE_TYPE'));
if ($arDiscount = $rsDiscounts->Fetch())
{
if (!isset($arFields['VALUE']))
$arFields['VALUE'] = doubleval($arDiscount['VALUE']);
if (!isset($arFields['VALUE_TYPE']))
$arFields['VALUE_TYPE'] = $arDiscount['VALUE_TYPE'];
if (self::TYPE_PERCENT == $arFields['VALUE_TYPE'] && 100 < $arFields['VALUE'])
{
$APPLICATION->ThrowException(GetMessage("BT_MOD_CATALOG_DISC_ERR_BAD_VALUE"), "VALUE");
return false;
}
}
else
{
$APPLICATION->ThrowException(str_replace('#ID#', $ID, GetMessage("BT_MOD_CATALOG_DISC_ERR_BAD_ID")), "ID");
return false;
}
}
$stackCacheManager->Clear("catalog_discount");
$strUpdate = $DB->PrepareUpdate("b_catalog_discount", $arFields);
if (!empty($strUpdate))
{
$strSql = "UPDATE b_catalog_discount SET ".$strUpdate." WHERE ID = ".$ID." AND TYPE = ".self::ENTITY_ID;
$DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
if (isset($arFields['HANDLERS']))
self::updateDiscountHandlers($ID, $arFields['HANDLERS'], true);
}
return $ID;
}
示例2: _Update
static public function _Update($ID, &$arFields)
{
global $DB;
global $stackCacheManager;
global $USER;
global $APPLICATION;
$ID = intval($ID);
if ($ID <= 0)
return false;
$arFields1 = array();
if (array_key_exists('CREATED_BY',$arFields))
unset($arFields['CREATED_BY']);
if (array_key_exists('DATE_CREATE',$arFields))
unset($arFields['DATE_CREATE']);
if (array_key_exists('TIMESTAMP_X', $arFields))
unset($arFields['TIMESTAMP_X']);
if (isset($USER) && $USER instanceof CUser && 'CUser' == get_class($USER))
{
if (!array_key_exists('MODIFIED_BY', $arFields) || intval($arFields["MODIFIED_BY"]) <= 0)
$arFields["MODIFIED_BY"] = intval($USER->GetID());
}
$arFields1['TIMESTAMP_X'] = $DB->GetNowFunction();
if (!CCatalogDiscount::CheckFields("UPDATE", $arFields, $ID))
return false;
if (isset($arFields['VALUE']) != isset($arFields['VALUE_TYPE']))
{
$rsDiscounts = CCatalogDiscount::GetList(array(),array('ID' => $ID), false, array('nTopCount' => 1), array('ID', 'VALUE', 'VALUE_TYPE'));
if ($arDiscount = $rsDiscounts->Fetch())
{
if (!isset($arFields['VALUE']))
$arFields['VALUE'] = doubleval($arDiscount['VALUE']);
if (!isset($arFields['VALUE_TYPE']))
$arFields['VALUE_TYPE'] = $arDiscount['VALUE_TYPE'];
if ('P' == $arFields['VALUE_TYPE'] && 100 < $arFields['VALUE'])
{
$APPLICATION->ThrowException(GetMessage("BT_MOD_CATALOG_DISC_ERR_BAD_VALUE"), "VALUE");
return false;
}
}
else
{
$APPLICATION->ThrowException(str_replace('#ID#', $ID, GetMessage("BT_MOD_CATALOG_DISC_ERR_BAD_ID")), "ID");
return false;
}
}
$stackCacheManager->Clear("catalog_discount");
$strUpdate = $DB->PrepareUpdate("b_catalog_discount", $arFields);
if (!empty($strUpdate))
{
$arAdd = array();
if (!empty($arFields1))
{
foreach ($arFields1 as $key => $value)
{
$arAdd[] = $key."=".$value;
}
$strUpdate .= ', '.implode(', ', $arAdd);
}
$strSql = "UPDATE b_catalog_discount SET ".$strUpdate." WHERE ID = ".$ID." AND TYPE = ".DISCOUNT_TYPE_STANDART;
$DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
}
return $ID;
}