Welcome Guest, Not a member yet? Register   Sign In
Dynamic Config File
#1

(This post was last modified: 03-14-2015, 05:21 AM by wolfgang1983.)

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 

Code:
$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:
<?php

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

foreach( 
$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.
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB