Reputation: 592
I've been working on a CI application and I came across an issue.
Instead of using a CronJob, I want to acomplish the following:
normally, when a user opens my website CodeIgniter loads in the background. When CI finishes loading I want to call a function from a model that I've written. How can I acomplish this?
(I don't know which controller would be loaded by the viewer, hence my confusion)
Hopefully you understood me and I'm awaiting your answers
Upvotes: 0
Views: 441
Reputation: 7266
I suggest you read about Hooks in CodeIgniter. You can specify at what point in the application you want the hook to run, and from what you describe the post_system
hook is what you need.
post_system Called after the final rendered page is sent to the browser, at the end of system execution after the finalized data is sent to the browser.
In the hook definition you specify what class and method to run.
$hook['pre_controller'] = array(
'class' => 'MyClass',
'function' => 'Myfunction',
'filename' => 'Myclass.php',
'filepath' => 'hooks',
'params' => array('beer', 'wine', 'snacks')
);
Upvotes: 1