Beispiel #1
0
 public static function Update($ID, $arFields)
 {
     global $DB;
     $ID = (int) $ID;
     if ($ID <= 0) {
         return false;
     }
     if (!CCatalogExport::CheckFields("UPDATE", $arFields)) {
         return false;
     }
     $strUpdate = $DB->PrepareUpdate("b_catalog_export", $arFields);
     if (!empty($strUpdate)) {
         $strSql = "update b_catalog_export set " . $strUpdate . " where ID = " . $ID . " and IS_EXPORT = 'Y'";
         $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     }
     return $ID;
 }
 function Update($ID, $arFields)
 {
     global $DB;
     global $USER;
     $ID = intval($ID);
     $boolNoUpdate = false;
     $arFields1 = array();
     foreach ($arFields as $key => $value) {
         if (substr($key, 0, 1) == "=") {
             if ('=LAST_USE' == $key) {
                 if ($value == $DB->GetNowFunction()) {
                     $arFields1['LAST_USE'] = $DB->GetNowFunction();
                     $boolNoUpdate = true;
                 }
             }
             unset($arFields[$key]);
         }
     }
     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 (!$boolNoUpdate) {
         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();
     } else {
         if (array_key_exists('MODIFIED_BY', $arFields)) {
             unset($arFields['MODIFIED_BY']);
         }
     }
     $arFields["IS_EXPORT"] = "Y";
     if (!CCatalogExport::CheckFields("UPDATE", $arFields)) {
         return false;
     }
     $strUpdate = $DB->PrepareUpdate("b_catalog_export", $arFields);
     foreach ($arFields1 as $key => $value) {
         if (strlen($strUpdate) > 0) {
             $strUpdate .= ", ";
         }
         $strUpdate .= $key . "=" . $value . " ";
     }
     $strSql = "UPDATE b_catalog_export SET " . $strUpdate . " WHERE ID = " . $ID . " AND IS_EXPORT = 'Y'";
     $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     return $ID;
 }