本文整理汇总了PHP中CSocNetFeatures::CheckFields方法的典型用法代码示例。如果您正苦于以下问题:PHP CSocNetFeatures::CheckFields方法的具体用法?PHP CSocNetFeatures::CheckFields怎么用?PHP CSocNetFeatures::CheckFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSocNetFeatures
的用法示例。
在下文中一共展示了CSocNetFeatures::CheckFields方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Add
/**
* <p>Сохраняет в базу запись о новом дополнительном функционале пользователя или группы.</p>
*
*
* @param array $arFields Параметры дополнительного функционала.
*
* @return int <p>Код записи, если сохранение прошло успешно. False - в противном
* случае.</p> <br><br>
*
* @static
* @link http://dev.1c-bitrix.ru/api_help/socialnetwork/classes/csocnetfeatures/csocnetfeatures.add.php
* @author Bitrix
*/
public static function Add($arFields)
{
global $DB;
$arFields1 = array();
foreach ($arFields as $key => $value) {
if (substr($key, 0, 1) == "=") {
$arFields1[substr($key, 1)] = $value;
unset($arFields[$key]);
}
}
if (!CSocNetFeatures::CheckFields("ADD", $arFields)) {
return false;
}
$db_events = GetModuleEvents("socialnetwork", "OnBeforeSocNetFeaturesAdd");
while ($arEvent = $db_events->Fetch()) {
if (ExecuteModuleEventEx($arEvent, array($arFields)) === false) {
return false;
}
}
$arInsert = $DB->PrepareInsert("b_sonet_features", $arFields);
foreach ($arFields1 as $key => $value) {
if (strlen($arInsert[0]) > 0) {
$arInsert[0] .= ", ";
}
$arInsert[0] .= $key;
if (strlen($arInsert[1]) > 0) {
$arInsert[1] .= ", ";
}
$arInsert[1] .= $value;
}
$ID = false;
if (strlen($arInsert[0]) > 0) {
$strSql = "INSERT INTO b_sonet_features(" . $arInsert[0] . ") " . "VALUES(" . $arInsert[1] . ")";
$DB->Query($strSql, False, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$ID = IntVal($DB->LastID());
if (array_key_exists("ENTITY_TYPE", $arFields) && array_key_exists("ENTITY_ID", $arFields)) {
unset($GLOBALS["SONET_FEATURES_CACHE"][$arFields["ENTITY_TYPE"]][$arFields["ENTITY_ID"]]);
}
$events = GetModuleEvents("socialnetwork", "OnSocNetFeaturesAdd");
while ($arEvent = $events->Fetch()) {
ExecuteModuleEventEx($arEvent, array($ID, $arFields));
}
if (defined("BX_COMP_MANAGED_CACHE") && array_key_exists("ENTITY_TYPE", $arFields) && array_key_exists("ENTITY_ID", $arFields)) {
$GLOBALS["CACHE_MANAGER"]->ClearByTag("sonet_features_" . $arFields["ENTITY_TYPE"] . "_" . $arFields["ENTITY_ID"]);
}
}
return $ID;
}
示例2: Update
function Update($ID, $arFields)
{
global $DB;
if (!CSocNetGroup::__ValidateID($ID)) {
return false;
}
$ID = IntVal($ID);
$arFields1 = array();
foreach ($arFields as $key => $value) {
if (substr($key, 0, 1) == "=") {
$arFields1[substr($key, 1)] = $value;
unset($arFields[$key]);
}
}
if (!CSocNetFeatures::CheckFields("UPDATE", $arFields, $ID)) {
return false;
}
$db_events = GetModuleEvents("socialnetwork", "OnBeforeSocNetFeaturesUpdate");
while ($arEvent = $db_events->Fetch()) {
if (ExecuteModuleEventEx($arEvent, array($ID, $arFields)) === false) {
return false;
}
}
$strUpdate = $DB->PrepareUpdate("b_sonet_features", $arFields);
foreach ($arFields1 as $key => $value) {
if (strlen($strUpdate) > 0) {
$strUpdate .= ", ";
}
$strUpdate .= $key . "=" . $value . " ";
}
if (strlen($strUpdate) > 0) {
$strSql = "UPDATE b_sonet_features SET " . "\t" . $strUpdate . " " . "WHERE ID = " . $ID . " ";
$DB->Query($strSql, False, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if (array_key_exists("ENTITY_TYPE", $arFields) && array_key_exists("ENTITY_ID", $arFields)) {
unset($GLOBALS["SONET_FEATURES_CACHE"][$arFields["ENTITY_TYPE"]][$arFields["ENTITY_ID"]]);
}
$events = GetModuleEvents("socialnetwork", "OnSocNetFeaturesUpdate");
while ($arEvent = $events->Fetch()) {
ExecuteModuleEventEx($arEvent, array($ID, $arFields));
}
if (defined("BX_COMP_MANAGED_CACHE")) {
$GLOBALS["CACHE_MANAGER"]->ClearByTag("sonet_feature_" . $ID);
}
} else {
$ID = False;
}
return $ID;
}