10-11-2010, 07:23 PM
[eluser]neomech[/eluser]
I'm trying to wrap my head around a small issue I'm having.
I have several functions sitting in my model, and I grab the name of one of them in my code dynamically, which I store as, say, $func_name.
Now I know that call_user_func($func_name, $var) is supposed to be the preferred method over $func_name($var). However, I can't seem to call any model functions from the controller using call_user_func.
This works:
This doesn't:
I suspect I should be able to call a function in the model from my controller using call_user_func, but if so, I'm doing something wrong. Any suggestions?
I'm trying to wrap my head around a small issue I'm having.
I have several functions sitting in my model, and I grab the name of one of them in my code dynamically, which I store as, say, $func_name.
Now I know that call_user_func($func_name, $var) is supposed to be the preferred method over $func_name($var). However, I can't seem to call any model functions from the controller using call_user_func.
This works:
Code:
$this->Sample_model->$func_name($var);
This doesn't:
Code:
//tried this way
$this->Sample_model->call_user_func($func_name,$var);
//also tried this way
call_user_func($this->Sample_model->$func_name, $var);