user3278647
user3278647

Reputation: 514

Time driven event in Codeigniter

Am trying to implement a function in Codeigniter that is called after end of each month so that it can remind users to pay a fee. How can i implement this in Codeigniter. Thank you.

Upvotes: 0

Views: 257

Answers (1)

Egor Sazanovich
Egor Sazanovich

Reputation: 5089

You need to create crontab job and call Your method at the end of each month (You can set it at crontab). You can access CodeIgniter methods via

php5 index.php yourcontroller yourmethod

Also be sure to check if request came from CLI in Your method:

<?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();
  }

}
?>

Upvotes: 1

Related Questions