CodeIgniter Forums
Using codeigniter database class separately - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: Using codeigniter database class separately (/thread-27125.html)



Using codeigniter database class separately - El Forum - 02-01-2010

[eluser]pilotdev[/eluser]
Hi there,

I've written a couple scripts that I want to run from cron or from command line that take advantage of CI libraries and potentially models.

I've built a library class and put it in my application folder. It currently only uses the database class with configuration settings in my app/config/database.php file. I'd like to be able to use the $this->db call to reference the class so that I can use the same class in my bootstrapped page serving classes.

Basically I want to use the CI framework for my command-line scripts but also using that same logic to serve pages.

If this doesn't make sense, I can give an example.

Thanks!

Dave


Using codeigniter database class separately - El Forum - 02-01-2010

[eluser]theprodigy[/eluser]
can you just write a cron job that cURL's to a url in your CI app? Not sure if that would work, but I don't see why it wouldn't. Just make a controller that handles what you need done via the cron, and then write a local script that curls to that url.


Using codeigniter database class separately - El Forum - 02-01-2010

[eluser]pilotdev[/eluser]
Great idea, but unfortunately that wont work in this case. My script basically acts as an RSS/Atom spidering tool - it can run for hours on end and a cURL request just wont cut it. I definitely need a more solid solution.

So basically CI can only function when it's bootstrapped through index.php? Is there any (easy) way to strip away all that complexity and just leverage the database and library classes?


Using codeigniter database class separately - El Forum - 02-02-2010

[eluser]pilotdev[/eluser]
Well I found this: http://codeigniter.com/wiki/CI_on_the_command_line/ looks to be the best solution for me.