CodeIgniter Forums
make a database call from index.php ??? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: make a database call from index.php ??? (/showthread.php?tid=32396)



make a database call from index.php ??? - El Forum - 07-22-2010

[eluser]Gewa[/eluser]
Hi,
I am making a multi-site codeigniter app. So i need in index.php to make a call to database and see the website's settings. I need just to be sure that the site is activated to show the content loading appropriate application folder. Is there a way to use db class here? what you could suggest?


make a database call from index.php ??? - El Forum - 07-22-2010

[eluser]WanWizard[/eluser]
No, there isn't.

I suggest using code in the index.php to determine the application folder based on the hostname, then deal with availability, access, maintenance mode, what have you, in your application (the MY_Controller seems like a logical place for these kind of checks).


make a database call from index.php ??? - El Forum - 07-22-2010

[eluser]Gewa[/eluser]
So you think in controller is better to check ? yeah easyer maybe.... thanks!


make a database call from index.php ??? - El Forum - 07-22-2010

[eluser]Gewa[/eluser]
then one thing. is it possible in index.php define a config variable, or a constant which I can acess in the controller?
What would be the best for this?
I need to pass somehow the web-site alias , then to make a check...


make a database call from index.php ??? - El Forum - 07-22-2010

[eluser]WanWizard[/eluser]
Easiest is to define a constant.

I have defined some extra as well, as I have the opposite issue: multiple frontends (versions of 'index.php'), with a single application.


make a database call from index.php ??? - El Forum - 07-22-2010

[eluser]coffeeandcode[/eluser]
[quote author="Gewa" date="1279813198"]then one thing. is it possible in index.php define a config variable, or a constant which I can acess in the controller?
What would be the best for this?
I need to pass somehow the web-site alias , then to make a check...[/quote]

I use the same WEBROOT, IMG, CSS, etc constants regardless of which framework I'm working with (keeps things consistent if I need to change frameworks), and with CI I define them at the top of index.php. It works great :-)