Welcome Guest, Not a member yet? Register   Sign In
Use CodeIgniter model classes from external script / cron
#1

[eluser]CARP[/eluser]
Hi

I'm developing a php script which sould take txt files from a folder, read them, and then I should use the CodeIgniter models to store the processed data into the MySQL tables.

This script will be called from a cron job in linux set to /5min.

How should I include and use the CodeIgniter classes/models so I can work as if I were in a CI Controller?

Thanks
#2

[eluser]Alucemet[/eluser]
Why does this script have to exist outside CI? Crons can call CI routes either through CLI or wget.

If it must exist outside CI, then you could include or require your db config file, then run your queries using PDO or mysqli. The db classes have way too many dependencies to try to use them outside CI.
#3

[eluser]CroNiX[/eluser]
Just call it directly from cron.
http://ellislab.com/codeigniter/user-gui...l/cli.html
#4

[eluser]CARP[/eluser]
Thanks guys. calling the controller from CLI did the work




Theme © iAndrew 2016 - Forum software by © MyBB