Welcome Guest, Not a member yet? Register   Sign In
Get a variable value inside a config file from MyController?
#1

[eluser]chefnelone[/eluser]
Hello,

I'd like to know if is there a way to do this:

In: application/library/My_controller.php I have:

Code:
$this->myVariable ='my value';

Then, I need to get myVariable from within: applicaction/config/carabinier.php

something like:

Code:
$config['myVariable'] = ? //should get $this->myVariable

thanks
#2

[eluser]cideveloper[/eluser]
Maybe I don't understand what you are trying to do here, but isn't that backwards? Don't you usually set values in the config file and then access them in controllers/models?
#3

[eluser]chefnelone[/eluser]
[quote author="cideveloper" date="1296771441"]Maybe I don't understand what you are trying to do here, but isn't that backwards? Don't you usually set values in the config file and then access them in controllers/models?[/quote]

You're right but I need that a value in a config file take its value from a database. So, I took it in My_controller and I just need to pass it to a config file.
#4

[eluser]cideveloper[/eluser]
Why don't you just dynamically set the config variable in your MY_Controller using

Code:
$this->config->set_item('item_name', 'item_value');
#5

[eluser]chefnelone[/eluser]
[quote author="cideveloper" date="1296787385"]Why don't you just dynamically set the config variable in your MY_Controller using

Code:
$this->config->set_item('item_name', 'item_value');
[/quote]

Good idea... but not working

i have in config/carabiner.php:

Code:
$config['dev'] = FALSE;


Then as you said i added to MY_Controller

Code:
this->config->set_item('dev', FALSE );

But it's just ignored
What's am I missing??




Theme © iAndrew 2016 - Forum software by © MyBB