Possible Duplicate:
PHP Using a variable when calling a static method
I've read through a few different posts on here (I.E. PHP Using a variable when calling a static method) when trying to use a variable on a static function, but I just can't seem to get the call_user_func_array() function to work the same as if I was able to call the variable directly in the class name.
PHP >= 5.3.0 Method:
$data = $factory_model::by_array(array(
$form_fields['name_field'] => $value
));
PHP < 5.3.0 Method:
$data = call_user_func_array(array($factory_model, 'by_array'), array(
$form_fields['name_field'] => $value
));
It's some code that I've inherited so I can't change that much on the models, but it should give the following output:
initiative_forecast_type Object
(
[id:initiative_forecast_type:private] => 0
[forecast_type:initiative_forecast_type:private] => TRTR
[tstamp] => 2012-06-11 12:52:07
)
Which it does using the standard PHP 5.3 Method (My user input/value was 'TRTR')
But if I use the call_user_func_array method I get:
initiative_forecast_type Object
(
[id:initiative_forecast_type:private] => 0
[forecast_type:initiative_forecast_type:private] =>
[tstamp] => 2012-06-11 12:52:07
)
So it's not setting the 'forecast_type' field. I've uploaded the model here - http://pastebin.ca/2160201
For reference - $factory_model = initiative_forecast_type_factory
I thought the 2 call_user_func_array() function should work the same as the 5.3.0 method, but it doesn't seem to be - Can anyone point me in the right direction?
Thanks! Christian