![]() |
accessing models - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: accessing models (/showthread.php?tid=14799) |
accessing models - El Forum - 01-15-2009 [eluser]Russell Keith[/eluser] I am very confused. I have three models MRecords, MMail, and MUsers. From withing MRecords I can call my user function from MUsers to get the username, but I can't call my function from MMail to send a message I get the folloing error. Quote:A PHP Error was encountered Here is a section of the code that is causing me trouble. Code: class MRecords extends Model { Thanks in advance for any help. accessing models - El Forum - 01-15-2009 [eluser]everdaniel[/eluser] Well you should load the model you're going to use first (MMail): Code: $this->load->model('MMail'); accessing models - El Forum - 01-15-2009 [eluser]Russell Keith[/eluser] I have it loaded in the autoload file. I can use it from the view or the controller just fine. I just can't use it from another model. Code: $autoload['model'] = array('MUsers','MPosting','MRecords','MLdap','MMail','MSettings','MAttachment'); accessing models - El Forum - 01-15-2009 [eluser]Colin Williams[/eluser] It's always best, when outside of a controller, to use the get_instance() function and call other libs/models from it. Code: $ci =& get_instance(); accessing models - El Forum - 01-15-2009 [eluser]Russell Keith[/eluser] Perfect, thank you. |