CodeIgniter Forums
How much PHP should you use in a view? - 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: How much PHP should you use in a view? (/showthread.php?tid=46902)



How much PHP should you use in a view? - El Forum - 11-19-2011

[eluser]Unknown[/eluser]
Hi Guys,

I have just started building my first CI powered app as well as being my first MVC structured project. I'm an EE user and so far i'm loving it.

I have a thing about doing things properly and want to get the structure just right. Having thoroughly explored the user docs and tutorials and having a basic version up and running, i'm running into issues about where to place some php code:

My controller loads my model, it then call the model method which query's the database and returns the records. I then load the view and pass the records to it.

1.

I'm getting confused when it comes to the php processing that i need to do to the the returned records, where would i do this? In the view? or in the controller? or using some other technique? In some cases there could be a fair bit of processing of the results and I want to make sure i get it right.

2.
I might what to declare my own functions that I would need to use in the process above and else where. Do i need to create and load my own helper file for this?

Any feedback would be really appreciated!

Many thanks,

Sam