[eluser]pioSko[/eluser]
Hi,
I've have successfully setup a db_sessions+Lang_Selection config and have reached a point where I want the languages array to be filled with those "active" in my mySQL database.
the setup's like this...
autoload.php
Code:
...
$autoload['libraries'] = array('database', 'session', 'lang_detect');
...
$autoload['config'] = array('lang_detect');
...
lang_detect.php
Code:
...
$config['lang_avail'] = array();
$langs_query = $this->db->query('SELECT * FROM `ci_languages` WHERE `active` = 1');
foreach ($langs_query->result_array() as $langs_row) {
$config['lang_avail'][$langs_row['code']] = $langs_row['code'];
// print $langs_row['code'];
}
...
$config['lang_default'] = 'en';
$config['lang_selected'] = 'en';
...
now.. what i'm trying to get from the database is something like this:
Code:
$config['lang_avail'] = array(
'pl' => 'pl',
'en' => 'en',
'de' => 'de',
);
BUT, what i get in the browser is this:
Quote:A PHP Error was encountered
Severity: Notice
Message: Undefined property: CI_Config::$db
Filename: config/lang_detect.php
Line Number: 13
Fatal error: Call to a member function query() on a non-object in E:\Work\Web\WWW\vacaero.com.pl\system\application\config\lang_detect.php on line 13
now, what I'm thinking is that it's trying to access the database ($this->db) before it actually autoloads it (I may be wrong).
Any ideas on how I can go about doing this?