CodeIgniter Forums

Full Version: Dynamic Config File
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have just been working on a config file called config_setting.php I wanted to get my library file loaded in to it and found it hard. So I thought how about doing dynamic setup. And now I have got it working.

If on your database table you had column called item_name and next to that column called item_value  Just like in user guide 

$this->config->set_item('item_name', 'item_value');

And then I could make code below. config/yourname.php make sure you autoload it.

PHP Code:

require_once(BASEPATH .'database/DB'EXT );

$db =& DB();

$query $db->get('tablename');

$db->where('id''0'); // Demo id do what your after

$result $query->result();

$result as $row ) {
  $config[$row->item_name] = $row->item_value;

It all works fine you should be able now to get item just by $this->config->item('item_value'); "Note: item_value just sample name" like in user guide.