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

How to make center align child div

 How to make center align child div?   Suppose you have 2 Div tag. And want the make inner tag center <div id="d1">      ...

Ads Inside Post

Powered by Blogger.

Arsip

Blog Archive