![]() |
Problem accessing method in model - 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: Problem accessing method in model (/showthread.php?tid=23474) |
Problem accessing method in model - El Forum - 10-12-2009 [eluser]jloosli[/eluser] I'm sure this is something simple that I'm overlooking, but after hours of troubleshooting and web searches, I can't figure this out. I have a model called Units that looks like this: Code: class Units extends Model { Code: $this->load->model('units'); I get the following CI error: Undefined property: CI_Loader::$units as well as the PHP Error: Fatal error: Call to a member function getActive() on a non-object in C:\xampp\htdocs\ci\system\application\views\invoice.php on line 12 I'm pretty sure that the model is loading, because I commented out line 12, enabled the profiler, and saw the memory usage change when I commented out the line to load the model. So...I'm stumped. Any idea why I can't see this method in this view? Problem accessing method in model - El Forum - 10-12-2009 [eluser]Neeraj Kumar[/eluser] I think you are trying to load models in your view, which is a bad bad idea. Try loading model in controller and pass only the data from model to view. Problem accessing method in model - El Forum - 10-12-2009 [eluser]jloosli[/eluser] <slap head>Wow. I feel dumb. Loaded in controller and worked like a charm. </slap head> Thanks a lot. I figured it was bad form, but I didn't realize that it doesn't work to load a model in a view. |