![]() |
Loading items from database for custom config file? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Loading items from database for custom config file? (/showthread.php?tid=61078) |
Loading items from database for custom config file? - El Forum - 09-12-2014 [eluser]Skoobi[/eluser] Hi I've created a config file for my site items like the site name site email and so on but i want to try and store them in the database and have the config file load them from there. At the moment i have my config file my_config.php : Code: $config['site_name'] = 'My CMS'; but what i want to do is pull it from the database so it comes as an array. Code: $config['site_name'] = $settings['site_name']; Is there a way i can do this like i do in the controllers??? Cheers Chris Loading items from database for custom config file? - El Forum - 09-13-2014 [eluser]InsiteFX[/eluser] If you use the CI Active Record then you can return it as an array. See the Users Guide on the Database Active Record and Query Results. Loading items from database for custom config file? - El Forum - 09-13-2014 [eluser]Skoobi[/eluser] I have tried but i get this error Code: A PHP Error was encountered Heres the code I've tried Code: $this->load->database(); Im pretty sure I've done it wrong!!! Cheers Chris Loading items from database for custom config file? - El Forum - 09-13-2014 [eluser]InsiteFX[/eluser] You need to use the CI Super OBject to access anything in a custom library etc; Code: $CI = get_instance(); Loading items from database for custom config file? - El Forum - 09-14-2014 [eluser]Skoobi[/eluser] Brilliant many thanks for your help that worked a charm! Cheers Chris |