【发布时间】:2016-03-22 06:34:00
【问题描述】:
我之前也遇到过类似的问题,但它已经解决了,但即使在知道它是如何完成的之后,这还是非常令人困惑。所以我在控制器上编写了一个函数,它从 MySQL 数据库接收数据并使用代码点火器函数发送电子邮件。所以这里是控制器代码
public function sendEmailToNewBorrower() {
//fetch tha data from the database
$this->load->model('payment_plan');
$foo = $this->payment_plan->getInfoToNotifyBorrowerForNewLoan();
$result = json_decode(json_encode($foo), true);
$this->load->library('email'/*, $config*/);
$this->email->from('info@loaners.club', 'Loaners CLub');
$this->email->to($result->Email);
$this->email->subject('Consumer Credit Information');
//$msg = $this->load->view('mypayment_view', '', true);
$name = ($result->Fullname);
$TotalAmountOfLoan = ($result->capital_payment);
$BorrowedAmount = ($result->borrowed_amount);
$LCcomission = ($result->amount_invoiced);
$Interest = ($result->interest_payment);
$Cur = ($result->Abbreviation);
$duedate = ($result->duedate);
$installment = ($result->instalmentnbr);
$BorrowerInterest = ($result->Interest);
$overdueInterest = ($result->overdue_interest);
$APR = ($result->total_payment);
$BorrowingPeriod = ($result->Loantime);
$msg1 =('https://apps.facebook.com/jussintestins/index.php');
$this->email->message(
'Hello! '.$name."\n"."\n"
.'You have a loan and we would like you to know all information about your loan. '."\n"."\n"."\n"
.'Loan information'."\n"."\n"
.'Total Borrowed Amount: '.$cur.' '.$BorrowedAmount.'.'."\n"
.'Loaners Club Comission: '.$cur.' '.$LCcomission.'.'."\n"
.'Total Payment : '.$cur.' '.$TotalAmountOfLoan.'.'."\n"
.'Installments :'.$installment.'.'."\n"
.'Interest Rate :'.$BorrowerInterest.'%.'."\n"
.'Interest Paid :'.$Interest.'%.'."\n"
.'Over due payment interest :'.$overdueInterest.'%.'."\n"
.'Your borrowing period: '.$BorrowingPeriod.'.'."\n"
."\n"."\n"
.'You have the right to withdraw the money'."\n"
.'You can click this link to pay your loan.'.'Something heere'.'.'."\n"."\n"."\n"
.'Thank you for using Loaners Club and we would like you to see all our other offers here '.$msg1."\n"."\n"
.'For more information contact info@loanersclub.com '
."\n"
."\n"
.'Have a great day! Loaners Club'
);
$returnvalue = $this->email->send();
if(!$returnvalue) {
alert("email failed to send");
} else {
$data=array('notified_borrower'=>current_time,'current_time'=>date('Y-m-d H:i:s'));
$this->db->update('payment_plan', $data);
}
}
所以当我调试程序时,它显示我确实从数据库中获取了数据。 但是当我检查 $result 时,它向我显示了这一点。
所以现在我不知道为什么会发生这种情况,因为我没有在那里存储任何信息,但我确实收到一个错误,说无法读取长度。还有一点就是最后的更新部分也没有更新。
【问题讨论】:
标签: php mysql codeigniter model-view-controller controller