Welcome Guest, Not a member yet? Register   Sign In
how to retrieve a post_controller_constructor variable in models?
#1

[eluser]Unknown[/eluser]
I set value to a language related variable (actually a property) in post_controller_constructor this way:

Code:
$ci =& get_instance();
...
$ci->lngcode = some_value;

I can retrieve this variable in views: $this->lngcode, but it is not possible in models, as $this->lngcode throws an error here. Unfortunately, i need this value in a model.

I am relatively new to CI so my first question is: why $this->lngcode is wrong here in the model?

Is it OK (a good practice?) to retrieve this variable by referencing the CI superobject in the model (i tested and it works):

Code:
$ci =& get_instance();
...
echo $ci->lngcode // do something with the value

or should i pass this value in the controller as a parameter to the model's method?

Thx for help!


Messages In This Thread
how to retrieve a post_controller_constructor variable in models? - by El Forum - 12-25-2010, 03:56 PM



Theme © iAndrew 2016 - Forum software by © MyBB