Welcome Guest, Not a member yet? Register   Sign In
Keeping models out of views - applying a function to a result array
#1

[eluser]mattpointblank[/eluser]
Hi all,

I'm looping through a set of database rows in my view. Simple enough. However, I want to apply a function to clean up dates and work out date differences inside this loop. I've put my function to do this in my model, but I'm calling the function from inside the view, which I've read is bad practice. I'm trying to keep as little code as possible in my views, so I'd definitely like a better method. How does everyone else do things like this? I could loop through my result array in the model before returning it and apply the function there, but then I have to loop through my resultset twice (once in the model to apply the function, and once in the view to display it). Is there a better way that hasn't occurred to me?

Thanks
Matt


Messages In This Thread
Keeping models out of views - applying a function to a result array - by El Forum - 07-09-2009, 06:36 AM



Theme © iAndrew 2016 - Forum software by © MyBB