![]() |
newbie: Seperating Controllers Properly - 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: newbie: Seperating Controllers Properly (/showthread.php?tid=33010) |
newbie: Seperating Controllers Properly - El Forum - 08-12-2010 [eluser]matt_a[/eluser] Hello everyone! I'm quite familiar with PHP, however I just came to CodeIgniter and this is my first experience with the MVC pattern. So please, bare with me! I'm concerned that my controller(s) are not designed properly. For example, controller functions that simply display a view vs. controller functions that process the data. To make things a little more clear, I'm creating a "User" controller that interacts with my "User_model." Inside the controller, I have functions such as login(), which simply display the login view. When submitted, the data is passed to the User controller to a function called "verify_login." For some reason, it strikes me that login() should be doing both jobs. As I'm typing this I see that my way of doing this probably isn't "wrong." I'm just a really paranoid programmer who likes to do things the most efficient way. Does anyone have any suggestions? newbie: Seperating Controllers Properly - El Forum - 08-12-2010 [eluser]Buso[/eluser] I like checking if the post hast been submitted, so I can do both things in the same method: Code: if( ! $this->input->post('submit')) { But your first choice is right too, it's a matter of taste newbie: Seperating Controllers Properly - El Forum - 08-12-2010 [eluser]matt_a[/eluser] :red: It's as easy as that! After ditching procedural PHP and coming to OOP and CodeIgniter, I guess I forgot some of the very basics :ohh: Thanks Buso. |