Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter / MVC best practices
#1

[eluser]Unknown[/eluser]
I am just an infant when it comes to working with CodeIgniter and the MVC concepts. I started with the Zend Framework, which seems really powerful but really complicated for a beginner. Working with CodeIgniter has helped me come a lot closer to understanding the idea of a MVC structured website.

From my understanding, models handle the "business logic", the views display the output, and the controller is suppose to hook them all together. Now, I want to keep as much PHP code out of my view files as possible. So, do I format my displayed output in a model and pass that to the controller to pass it to the view or should I just use a model for database logic and save the formatting for the controller?

I realize that it could be done either way. But for the sake of a clean MVC structure which is the best practice?

Thanks for any help.
#2

[eluser]xwero[/eluser]
If the same data isn't requested elsewhere i put the formating in the query but this means i loose the flexibility to go to another database as the functions are mostly database specific.

I don't see the use of formating the data in the controller to loop it again in the view. if data needs formating use functions in the view. if the formating requires multiple functions or parameters that can be set globally wrap them to keep the php code as short as possible.
#3

[eluser]JayTee[/eluser]
There was a similar discussion about this in another thread:

http://ellislab.com/forums/viewthread/107448/#540943




Theme © iAndrew 2016 - Forum software by © MyBB