Welcome Guest, Not a member yet? Register   Sign In
Loading Config from Database
#1

[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

Severity: Notice

Message: Trying to get property of non-object

Filename: hooks/config.php

Line Number: 15

Fatal error: Call to a member function get() on a non-object in E:\XAMPP\htdocs\Donator-Interface\application\hooks\config.php on line 15


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');

function pre_controller()
{

    $CI = & get_instance( );
    var_dump($CI);

    $results = $CI->db->get('settings')->result();

    foreach ($results as $setting) {

        $CI->config->set_item($setting->id, $setting->value);

    }//End of foreach

}
?>

config/hooks.php
Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$hook['pre_controller'] = array(
                                'class'    => '',
                                'function' => 'pre_controller',
                                'filename' => 'config.php',
                                'filepath' => 'hooks',
                                );

/* End of file hooks.php */
/* Location: ./application/config/hooks.php */

log-file
Code:
DEBUG - 2012-09-07 19:09:23 --> Config Class Initialized
DEBUG - 2012-09-07 19:09:23 --> Hooks Class Initialized
DEBUG - 2012-09-07 19:09:23 --> Utf8 Class Initialized
DEBUG - 2012-09-07 19:09:23 --> UTF-8 Support Enabled
DEBUG - 2012-09-07 19:09:23 --> URI Class Initialized
DEBUG - 2012-09-07 19:09:23 --> Router Class Initialized
DEBUG - 2012-09-07 19:09:23 --> Output Class Initialized
DEBUG - 2012-09-07 19:09:23 --> Security Class Initialized
DEBUG - 2012-09-07 19:09:23 --> Input Class Initialized
DEBUG - 2012-09-07 19:09:23 --> Global POST and COOKIE data sanitized
DEBUG - 2012-09-07 19:09:23 --> Language Class Initialized
ERROR - 2012-09-07 19:09:23 --> Severity: Notice  --> Trying to get property of non-object E:\XAMPP\htdocs\Donator-Interface\application\hooks\config.php 15


Messages In This Thread
Loading Config from Database - by El Forum - 09-07-2012, 11:02 AM
Loading Config from Database - by El Forum - 09-07-2012, 12:44 PM
Loading Config from Database - by El Forum - 09-07-2012, 01:11 PM
Loading Config from Database - by El Forum - 09-07-2012, 01:32 PM
Loading Config from Database - by El Forum - 09-07-2012, 01:41 PM
Loading Config from Database - by El Forum - 09-17-2012, 12:50 PM



Theme © iAndrew 2016 - Forum software by © MyBB