Welcome Guest, Not a member yet? Register   Sign In
(CI 2.0) Problem Extending CI_Config
#1

[eluser]mdvaldosta[/eluser]
Created a file named MY_Config.php and placed inside the application/libraries folder:

Code:
class MY_Config extends CI_Config {
    
    function get($name)
    {
        $this->CI =& get_instance();

        $query = $this->CI->db->get_where('config', array('name' => $name));
        $result = $query->row_array();

        return $result['value'];
    }
}

and it will not work when I call from a controller:

Code:
$this->config->get('whatever')

The above code WILL work if I name the file/class something else and load it as a library, however I'd rather extend the default config class since it autoloads. What am I missing here?

I'm getting a fatal error, undefined method CI_Config::get()
#2

[eluser]Twisted1919[/eluser]
Not sure, but i think the config library is a core class, therefore it should stay in the core folder ?
#3

[eluser]mdvaldosta[/eluser]
Lol, yeah putting it in the core folder did it (makes sense). The documentation I read had it extended as a library. Oh well... I should have asked for help an hour ago. Thanks bro.
#4

[eluser]Twisted1919[/eluser]
NP, glad you sorted it out .




Theme © iAndrew 2016 - Forum software by © MyBB