![]() |
question: how to pass a variable from model to view - 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: question: how to pass a variable from model to view (/showthread.php?tid=29013) |
question: how to pass a variable from model to view - El Forum - 03-27-2010 [eluser]johansonevR[/eluser] hi there, I have a function inside a 'model' Code: function register($name){ I can call the function from the 'controller' Code: $this->my_model->register($name); question: how to pass a variable from model to view - El Forum - 03-28-2010 [eluser]Ben Edmunds[/eluser] You could do something like this: Code: MODEL or you could return an array with the error/success message. Or create a getter and setter for the errors. Many options... question: how to pass a variable from model to view - El Forum - 03-28-2010 [eluser]johansonevR[/eluser] tnx question: how to pass a variable from model to view - El Forum - 03-28-2010 [eluser]Ben Edmunds[/eluser] If you do it the way I posted you might want to use === TRUE instead of just ==. Just wanted to clarify... question: how to pass a variable from model to view - El Forum - 03-28-2010 [eluser]Zack Kitzmiller[/eluser] You can store the error message in a session variable, but I would do that in the controller. It makes for more re-usable code. In Model: Code: function get_name_exists($name){ In Controller Code: function some_function() { However, I'd probably tackle this is a completely different way. |