• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dynamic Config File

#1
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.


Attached Files Thumbnail(s)
   
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.