Codeigniter中的时间驱动事件


Time driven event in Codeigniter

Am试图在Codeigniter中实现一个函数,该函数在每个月底后调用,以便提醒用户支付费用。如何在Codeigniter中实现此功能。非常感谢。

您需要创建crontab作业,并在每个月底调用Your方法(您可以在crontab中设置它)。您可以通过访问CodeIgniter方法

php5 index.php yourcontroller yourmethod

此外,请确保在您的方法:中检查请求是否来自CLI

<?php
class Yourcontroller extends CI_Controller {
     function index(){
     }
  function yourmethod(){
    if(!$this->input->is_cli_request())
       die('CLI only');
    // add Your code below like this:
    $this->load->model('remindermodel');
    $this->remindermodel->remindToPay();
  }
}
?>