Loading Config from Database |
[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
[eluser]Madigan[/eluser]
I'm an utter PHP newbie, but shouldn't it be Code: $CI =& get_instance( ); Code: $CI = & get_instance( );
[eluser]Arrow768[/eluser]
The Space is not the Problem I have tried it out, but I still get the same Error. thanks for trying
[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()
[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');
[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 |
Welcome Guest, Not a member yet? Register Sign In |