[SOLVED] Get config values from DB |
[eluser]Pascal Kriete[/eluser]
As long as the rest of the application is well designed and the server is set up correctly, it shouldn't be a problem.
[eluser]Colin Williams[/eluser]
The only tax on your server would be the extra query needed to load the config items from the DB. I don't see why the controller needs to be extended at all. If you have a library being autoloaded, you're going to have access to the config items via the library at any time.
[eluser]internut[/eluser]
Can anybody lend a hand on this error after creating a library: Library: Load_Settings.php Called using: $this->load->library('Load_Settings'); Which works fine until I get into a database call. Error: load settings gets printed here Fatal error: Call to a member function query() on a non-object in C:\Program Files\WebServer\Abyss Web Server\htdocs\php\NEW\admin\system\application\libraries\Load_Settings.php on line 8 /libraries/Load_Settings.php: Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); database is on autoload and works fine. Just not here so I must be missing something. Help greatly appreciated.
[eluser]Pascal Kriete[/eluser]
Libraries don't extend the CI super object, so you need to grab the reference: Code: $CI =& get_instance();
[eluser]internut[/eluser]
Ok going to make the changes. I appreciate your response. Is that the same for models? Would it be better to do this as a model or library or same?
[eluser]internut[/eluser]
Thanks Inparo making progress. Why am I only getting the first result from the settings table? Structure: Table: settings --> Fields name & setting: Code: function Load_Settings() { Its returning the first record: --> name --> admin_url --> setting --> http://www.your-domain.com/mm2/admin.php Trying to figure out why its not cycling thru them all.
[eluser]internut[/eluser]
Ok I'm switched up to this: Code: class Load_Settings { I'm getting all results from the "settings" table. I'm curious if the code: Code: $CI->config->set_item($row->name, $row->setting); is setting the name = setting variables into $config ? there is a name = setting of: username = xxx Can this username config be called all over now? If so how? $config[username] ?
[eluser]flojon[/eluser]
[quote author="internut" date="1215503453"] ... there is a name = setting of: username = xxx Can this username config be called all over now? If so how? $config[username] ?[/quote] You can get the config values by using something like this: Code: $this->config->item('username');
|
Welcome Guest, Not a member yet? Register Sign In |