![]() |
Calling one model from another model, how? - 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: Calling one model from another model, how? (/showthread.php?tid=16866) |
Calling one model from another model, how? - El Forum - 03-18-2009 [eluser]Gewa[/eluser] Hi, How can I load one model from another model? Or one in one function of model call another function of model? Calling one model from another model, how? - El Forum - 03-18-2009 [eluser]The Wizard[/eluser] yeah surely load it and access it as normal ![]() Calling one model from another model, how? - El Forum - 03-18-2009 [eluser]TheFuzzy0ne[/eluser] You will need to call $this->_assign_libraries() a second time on the first model after it's loaded the second model, otherwise the first second model will not be available to the first. Calling one model from another model, how? - El Forum - 03-18-2009 [eluser]Gewa[/eluser] The FuzzyOne can you give a detailed example? lets say in Foto_model.php I have function foto_data() Code: function foto_data($foto_id){ Like this??? Calling one model from another model, how? - El Forum - 03-18-2009 [eluser]TheFuzzy0ne[/eluser] I sit corrected. Your best bet would be to create a class property which references the $CI Super Object when the model is instantiated: Code: function __construct() and then you can access other models that way: Code: $this->CI->some_model->some_method(); Calling one model from another model, how? - El Forum - 03-19-2009 [eluser]srisa[/eluser] I load the model in the constructor and use it normally everywhere else. In your example, $this->load->model('ratings_model') should go in the constructor of foto_model.php. You can use the functions of ratings_model in other functions as you are doing now. Calling one model from another model, how? - El Forum - 03-19-2009 [eluser]Gewa[/eluser] Thank YOU ALLL!!!! Calling one model from another model, how? - El Forum - 05-29-2009 [eluser]Zac G.[/eluser] Why is it that you still have to load the model manually even if it's loaded in the auto loader? Calling one model from another model, how? - El Forum - 05-29-2009 [eluser]TheFuzzy0ne[/eluser] You don't. What makes you say that? Calling one model from another model, how? - El Forum - 05-29-2009 [eluser]Zac G.[/eluser] For some reason, it wasn't working for me... I did that and then it worked? I must have made some other change as well...hmmm |