Calling model functions from views - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Calling model functions from views (/showthread.php?tid=5515) |
Calling model functions from views - El Forum - 01-24-2008 [eluser]Unknown[/eluser] I can't seem to do it. Every time I try, I get an error message like this: Quote:A PHP Error was encountered From the view file: Code: $this->load->model('mymodel'); From the model file: Code: function hello() Calling model functions from views - El Forum - 01-24-2008 [eluser]wiredesignz[/eluser] You can't load Models in your View, but you can access them from the View after they have been loaded in the Controller Calling model functions from views - El Forum - 01-24-2008 [eluser]Unknown[/eluser] [quote author="wiredesignz" date="1201233580"]You can't load Models in your View, but you can access them from the View after they have been loaded in the Controller[/quote] Oh! Thanks a lot. Calling model functions from views - El Forum - 01-25-2008 [eluser]Sawariya[/eluser] in controller $this->load->model('mymodel'); in view echo $this->mymodel->hello(); it will print hello... Calling model functions from views - El Forum - 01-25-2008 [eluser]sikkle[/eluser] I think if you try to create kind of partial, you can use helper to create them and call them in view. Good luck ! |