第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

防止日志中的重復(fù)條目

防止日志中的重復(fù)條目

PHP
元芳怎么了 2021-11-05 13:18:01
我有一個帶有一些代碼的垃圾郵件,我試圖防止日志發(fā)送垃圾郵件“已識別取消”,當(dāng)運行相同的代碼時有 3 個實例并且它是垃圾郵件。如果有重復(fù),我想防止我的日志中出現(xiàn)“取消已識別”垃圾郵件。有沒有辦法防止重復(fù)輸入“已識別取消”的日志?我有一些用于修復(fù)的偽代碼,但無法將其轉(zhuǎn)換為 php。   if($searchfor)    {        $searchfor = "Cancellation Identified";        $searchfor = true;        continue process_imports();    }if(!empty($contract)){    //Determine if contract has been cancelled based on the presence of a cancellation date.    if ((isset($data['cancelled_date'])) && (substr_count($data['sold_date'], '/') == 2) && ($contract->cancelled_date >= '2015-01-01')) {        //If cancelled determine if cancellation is new by comparing to previously cancelled contracts table.        $IsCancelled = ContractCancellation::LocateCancellation($contract->moxy_contract_id);        if (!$IsCancelled->first()) { //Contract is not in cancellations table, flag contract for later cancellations processing.            $contract->cancel_pending = 1;            if($contract->hold == '1'){                LogAction::add("Data Adjustment", "Hold Removed Due To Contract Being Cancelled.", 0, "", $contract->moxy_contract_id);            }            $contract->hold = 0;            $contract->save();            LogAction::add("Data Adjustment", "Cancellation Identified.", 0, "", $contract->moxy_contract_id);                                          }    }    $contract->cancel_miles = !empty($data['cancel_miles']) ? $data['cancel_miles'] : 0;    $contract->cancel_reason = !empty($data['cancel_reason']) ? $data['cancel_reason'] : NULL;    $contract->save();}
查看完整描述

1 回答

?
白板的微信

TA貢獻(xiàn)1883條經(jīng)驗 獲得超3個贊

正如評論中提到的,您可以使用Session helper 來記住日志是否已經(jīng)生成,以避免垃圾郵件發(fā)送您的日志。


<?php


if(empty(session('Cancellation_identified')) || session('Cancellation_identified') !== $contract->moxy_contract_id){

    session(['Cancellation_identified' => $contract->moxy_contract_id]);

    LogAction::add("Data Adjustment", "Cancellation Identified.", 0, "", $contract->moxy_contract_id);         

以上將檢查Cancellation_identified會話中是否存在。如果沒有,它會創(chuàng)建一個日志條目并將Cancellation_identified帶有其各自 ID的密鑰添加到會話中。在其他2情況下,您可以進(jìn)行相同的檢查。


請注意,這對于多個 HTTP 請求也很有用,$contract->moxy_contract_id因為每個請求很可能會有所不同。上面的代碼也會處理這個問題,因為我們也在檢查 ID 是否相等。


查看完整回答
反對 回復(fù) 2021-11-05
  • 1 回答
  • 0 關(guān)注
  • 196 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號