How do I call one Model\'s methods from a different Model?

Answer

Short answer: You don't

Long answer: You shouldn't actually be trying to do this. It implies that your design isn't quite right. (Your design may be right - I'm just saying that this implies that it's not (also, if you have to ask this question, this also suggests you probably shouldn't be doing this.)) Consider moving things around such that MY_Model or a library or helper contains the functionality you're trying to utilise in this way.

If you absolutely positively have to do this (and remember - you shouldn't) you can do the old $CI = get_instance() trick. Phil explains it in this thread but loosely it is simply this:

$ci =& get_instance();
$ci->load->model('Mymodel');
$ci->mymodel->mymethod();

All CODEIGNITER Questions

Ask your interview questions on codeigniter

Write Your comment or Questions if you want the answers on codeigniter from codeigniter Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---