Codeigniter 中的时间驱动事件
Time driven event in Codeigniter
我正在尝试在 Codeigniter 中实现一个在每个月结束后调用的功能,以便它可以提醒用户支付费用。我如何在 Codeigniter 中实现它。谢谢。
您需要创建crontab 作业并在每个月底调用您的方法(您可以在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();
}
}
?>
我正在尝试在 Codeigniter 中实现一个在每个月结束后调用的功能,以便它可以提醒用户支付费用。我如何在 Codeigniter 中实现它。谢谢。
您需要创建crontab 作业并在每个月底调用您的方法(您可以在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();
}
}
?>