CodeIgniter Forums
Database config loading too early - 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: Database config loading too early (/showthread.php?tid=19692)



Database config loading too early - El Forum - 06-16-2009

[eluser]CrazyMerlin[/eluser]
Hey guys!

I decided to autoload some features as I know I would need them throughout and encountered this error when autoloading the database library:

Code:
Message: Undefined variable: config

Filename: config/database.php

Line Number: 49

It seems that the config/database.php file is being loaded before the config/config.php file...which makes no sense, or the $config array is somehow being overwritten.

Any ideas?

//erlin!


Database config loading too early - El Forum - 06-16-2009

[eluser]TheFuzzy0ne[/eluser]
It sounds to me like you might be loading the database file manually as a config file. Check for any calls to $this->load->config('database');


Database config loading too early - El Forum - 06-16-2009

[eluser]CrazyMerlin[/eluser]
Nope, just ran a find on that string and it doesn't appear at all in the entire project.
Why use a global array anyway, why not the config property of the Config class?

//erlin!


Database config loading too early - El Forum - 06-16-2009

[eluser]drewbee[/eluser]
It should be irrelevant how they are loaded, as long as the database class is properly using $this->config->item();

At the very least, the config items would return an empty string.

Paste us your database config file.


Database config loading too early - El Forum - 06-16-2009

[eluser]TheFuzzy0ne[/eluser]
The database doesn't use the config class, it loads the file directly. That's why I suspect a call to $this->load->config(‘database’); is being made, since the config class looks for an array called "config". It's also possible that the code uses "quotes" instead of 'apostrophes'.