Problem:
How to load model in CodeIgniter view? It is not a good idea to load model in view, but sometime it is a requirement to load model in view.Solution:
Create the instance of CodeIgniter as below:$ci_inst =&get_instance();
Then load your model as below:
$ci_inst->load->model('model_name');
now you can access model as below:
$rs_truck=$ci_inst->model_name->function_method_name(parameter);
Example:
$ci_inst =&get_instance();$ci_inst->load->model('truck_model');
$rs_truck=$ci->truck_model->get_trucks_by_transporter_id(1);
0 comments:
Post a Comment