I have the fo开发者_如何学Cllowing code:
if($result = $this->Email->peopleFollowingEmail($follow['User']['email'], $viewer['User']['fname'].' '.$viewer['User']['lname'], $viewer['User']['username']))
{
$pf_model->id = $id;
$pf_model->saveField('sent_email', 1);
}
else
{
$pf_model->id = $id;
$pf_model->saveField('email_error', $result);
}
The Email
function either will return true
or return $errMessage
.
How do I store the error message in my db? I think my $result = ...
is wrong.
Try,
$result = $this->Email->peopleFollowingEmail($follow['User']['email'], $viewer['User']['fname'].' '.$viewer['User']['lname'], $viewer['User']['username']);
if($result === true)
{
$pf_model->id = $id;
$pf_model->saveField('sent_email', 1);
}
else
{
$pf_model->id = $id;
$pf_model->saveField('email_error', $result);
}
If it returns error message and it's a string you are doing it right. If its not a string you need to serialize it before passing it to database using serialize($result)
and unserialize($value)
when you want to read it back.
精彩评论