For smart Primates & ROBOTS (oh and ALIENS ).

Blogroll

Saturday, March 28, 2015

load model in view codeigniter

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);
Share:

0 comments:

Post a Comment

Multiple attribute passing in querySelectorAll

Multiple attribute passing in querySelectorAll     Here I am demonstrating code to how to pass multiple attributes in querySelectorAll. <...

Ads Inside Post

Powered by Blogger.

Arsip

Blog Archive