codeigniter, php, mysql, xhtml, css, jquery, flex web-development blog
Uncategorized
codeigniter: helper function to call library or model function in view
May 16th
Hi I am back again,
This time with two helper function that lets you call any function from any model or library, given you already have the model or library loaded into the instance.
This one calls a library function with a single parameter being passed.
-
function call_lib_func($library_name, $function_name, $parameters=null){
-
$ci = &get_instance();
-
$ci->load->library($library_name);
-
return $ci->$library_name->$function_name($parameters);
-
}
-
}
The next one calls a model function with a single parameter being passed.
-
function call_mod_func($model_name, $function_name, $parameters=null){
-
$ci = &get_instance();
-
$ci->load->model($model_name);
-
return $ci->$model_name->$function_name($parameters);
-
}
-
}
As of now multiple parameter are not yet supported but I will soon post an extension of these two functions that will support multiple parameters. If you choose to use any of these functions feel free to use but a link back to my site is appreciated
thanks,
thephpx
thephpx reloaded!
Jul 31st