Welcome Guest, Not a member yet? Register   Sign In
Creating dynamic configuration?
#1

[eluser]Samus[/eluser]
Hey guys, i'm trying to create a dynamic config item. By dynamic, I mean where I have the value of an item assigned based on database queries.

I've wrote a little something to set the config item, but for some reason the values from my queries don't get to my views properly..

Here's what my code snippet looks like:

Code:
function config_fetch()
    {
  
  $this->db->where('active', '1'); // If the setting is active  
  $this->db->select('code,name,value_type,int_value,text_value');  
  $query = $this->db->get('resources');
  
        foreach ($query->result() as $row)
        {
      if($row->value_type =='I' ) // If Integer
      {
           $this->set_item(strtolower($row->code),$row->int_value);
      }
      if($row->value_type =='T' ) // If Text
      {
           $this->set_item(strtolower($row->code),$row->text_value);
      }
So how I see it, if I have a value under the 'code' column named 'site_name' and then I had another value under the 'text_value' column called 'Codeigniter - teach me'. I should be able to do this in my view file:
Code:
$this->config->item('site_name');
and have it return: 'Codeigniter - teach me'.

Can anybody spot what I have done wrong?

Btw I have saved this as a model as it runs DB work..

I then had my controller look something like this:
Code:
class Home extends CI_Controller
{
public function Home ()
{
parent::__construct();
$this->load->model('dyn_config');
$this->dyn_config->config_fetch();
}
}

And yes, I had the database class on 'autoload'.

Any help will be appreciated please!




Theme © iAndrew 2016 - Forum software by © MyBB