Here I will show you how easy it is to load model inside another model in Codeigniter.
Say we have 2 models which are as follows:
class First_model extends Model
{
function First_model()
{
parent::Model();
}
function First_Function()
{
echo 'This is parent Function';
}
}
class Second_model extends Model
{
function Second_model()
{
parent::Model();
//Load First Model
$ci=& get_instance();
$ci->load->model('First_model');
}
function Second_Function()
{
//Call First model Function
$ci->First_model->First_Function();
}
}
You are Done.
Subscribe to:
Post Comments (Atom)
Thanks for your fine post.
ReplyDeleteUsing this way, Is it possible to call a controller function from another controller fucntion ?