Answer the question
In order to leave comments, you need to log in
Why don't identical records in the database match?
There is a code for creating a message:
foreach($this->errorsArray as $error){
$market=db\Market::findOne(['id'=>$error['marketId']]);
$action=db\Action::findOne(['id'=>$error['actionId']]);
$message .= "--------------- Error: Action: ".$action->name.", "."Market: ".$market->name.", Account: ".$error['login']." ------------". "\r\n";
$message .= "Action: ".$action->name. "\r\n";
$message .= "Market: ".$market->name. "\r\n";
$message .= "Account: ".$error['login']. "\r\n";
$message .= "Date: ".$error['date']. "\r\n";
$message .= "Message: ".$error['message']. "\r\n";
$message .= "-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------". "\r\n";
$message .= "\r\n";
}
$find= db\ErrorMessage::findOne(['date'=>$date->format('Y-m-d'),'message'=>$message]);
if ($find==null){
$errorMessage = new db\ErrorMessage();
$errorMessage->date=$date->format('Y-m-d');
$errorMessage->message=$message;
$errorMessage->save();
mail($to, $subject, $message, $headers);
}
Answer the question
In order to leave comments, you need to log in
I think the problem is in the line
which doesn't find anything. Try to start in addition to the message, save the md5 hash of messages in the database and search not by text, but by hash.
$errorMessage->message_hash=md5($message);
---
$find= db\ErrorMessage::findOne(['date'=>$date->format('Y-m-d'),'message_hash'=>md5($message]));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question