Welcome Guest, Not a member yet? Register   Sign In
Global Variables from database
#5

[eluser]adamp1[/eluser]
I have the same exact thing on my site. I solved it by having a model which interacts with the options table, so if I want the site name I call

Code:
$this->settings->item('site_name');

To save sever calls it caches all settings. I don't like the adding it to a config class since it could overwrite a previous set config value.

But loading settings from a database seem to be a very wasteful use of DB queries. I think it would be best to store them in a config file and write all changes to the file. Then you could load it like a normal config file (with each setting having a special prefix name).

Then you could just have a helper file to save you having to remember the prefix,

Code:
get_setting('site_name')

would call something like

$this->config->item('settings_site_name');


Messages In This Thread
Global Variables from database - by El Forum - 01-11-2008, 12:03 PM
Global Variables from database - by El Forum - 01-11-2008, 02:15 PM
Global Variables from database - by El Forum - 01-11-2008, 03:17 PM
Global Variables from database - by El Forum - 01-11-2008, 05:32 PM
Global Variables from database - by El Forum - 01-12-2008, 04:11 AM



Theme © iAndrew 2016 - Forum software by © MyBB