![]() |
Loading Config from Database - 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: Loading Config from Database (/showthread.php?tid=54419) |
Loading Config from Database - El Forum - 09-07-2012 [eluser]Arrow768[/eluser] Hi, I am trying to load my additional config from a Database. After some Google´ing I found the Hook-Method from vbsaltydog. (http://ellislab.com/forums/viewreply/967955/) When I load my page, I get the following Error: Code: A PHP Error was encountered What I have done until now: I load the database library with autoload I have enabled the Hooks in the config.php file I tried to make a var_dump of $CI (result is NULL) It would be great if you could help me with my problem. This are my files: hooks/config.php Code: <?php if ( !defined('BASEPATH') ) exit('No direct script access allowed'); config/hooks.php Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); log-file Code: DEBUG - 2012-09-07 19:09:23 --> Config Class Initialized Loading Config from Database - El Forum - 09-07-2012 [eluser]Madigan[/eluser] I'm an utter PHP newbie, but shouldn't it be Code: $CI =& get_instance( ); Code: $CI = & get_instance( ); Loading Config from Database - El Forum - 09-07-2012 [eluser]Arrow768[/eluser] The Space is not the Problem I have tried it out, but I still get the same Error. thanks for trying Loading Config from Database - El Forum - 09-07-2012 [eluser]PhilTem[/eluser] I think the problem is: Hooks are executed very early, so you might not have the DB class loaded (do you autoload it or in the controller?). You might also want to try Code: function pre_controller() ![]() Loading Config from Database - El Forum - 09-07-2012 [eluser]Arrow768[/eluser] I solved the Problem: hooks/Load_items.php Code: <?php if ( !defined('BASEPATH') ) exit('No direct script access allowed'); config/hooks.php Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); Loading Config from Database - El Forum - 09-17-2012 [eluser]Unknown[/eluser] For my hook to work: I extended the CI_Hooks, not the CI_Controller. I used post_controller_constructor in order to get the db, etc. I set enable_hooks to TRUE in the config.php Also, I am using version 1.7.2 which is worth mentioning. Cheers. -M |