Welcome Guest, Not a member yet? Register   Sign In
Best place to put AKA reading database from the config file..
#6

[eluser]CtheB[/eluser]
Hi hooks are things who needs to be loaded on a certain time in the initialisation proces.
Config files certainly doesn't need to be.

Having a quick look in the userguide:

Quote:If you would like to dynamically set a config item or change an existing one, you can so using:

$this->config->set_item('item_name', 'item_value');
Where item_name is the $config array index you want to change, and item_value is its value.

So in your main controller you can make a little method like this:
(in the constructer you load the model: $this->load->model('page_loader_model', 'loader', TRUE); )
Quote:
private function set_configuration()
{
$config = $this->loader->get_configuration();

foreach($config as $item)
{
$this->config->set_item($item->configurationKey, $item->configurationValue);
}
}

and then get the results from the model:
Quote:public function get_configuration()
{
$query = $this->db->query(" SELECT configurationKey,
configurationValue
FROM configuration
WHERE configurationActive IS TRUE
");
return $query->result();
}

And then your'r all set, you only have to call the set_configuration() method if necesarry.


Messages In This Thread
Best place to put AKA reading database from the config file.. - by El Forum - 05-06-2009, 04:06 PM



Theme © iAndrew 2016 - Forum software by © MyBB