Welcome Guest, Not a member yet? Register   Sign In
Nested Query Question (NEWBIE)
#7

[eluser]JesseR[/eluser]
[quote author="sl3dg3hamm3r" date="1263483317"]
If you have some heavy logic for retrieving data from a result-set (if field x = true, take field y etc.), I would encapsulate the query-object in an object (implement iterator), and encapsulate the logic there. This is in the sense of OOP, combine data and behavior in one place. In other words: Instead of returning the query-object in your model (which you don't have yet), let the model save the query and return the fields you need, implementing your mentioned logic. Since you would implement then the iterator, you would be able to use foreach on the model itself. Very handy.[/quote]

I don't completely follow. Would you mind providing an example of what you mean? I'm
not really versed in OOP. I have always just got by doing php with a non oop style.

[quote author="sl3dg3hamm3r" date="1263483317"]
In other words: Instead of returning the query-object in your model (which you don't have yet), let the model save the query and return the fields you need, implementing your mentioned logic. Since you would implement then the iterator, you would be able to use foreach on the model itself. Very handy.[/quote]

Are you saying to put my if statements in the view where my foreach displays or running a foreach in another file and then another foreach in my view?


Messages In This Thread
Nested Query Question (NEWBIE) - by El Forum - 01-13-2010, 03:49 PM
Nested Query Question (NEWBIE) - by El Forum - 01-13-2010, 04:38 PM
Nested Query Question (NEWBIE) - by El Forum - 01-13-2010, 04:55 PM
Nested Query Question (NEWBIE) - by El Forum - 01-13-2010, 05:26 PM
Nested Query Question (NEWBIE) - by El Forum - 01-13-2010, 11:05 PM
Nested Query Question (NEWBIE) - by El Forum - 01-14-2010, 03:35 AM
Nested Query Question (NEWBIE) - by El Forum - 01-14-2010, 07:12 AM
Nested Query Question (NEWBIE) - by El Forum - 01-14-2010, 08:42 AM
Nested Query Question (NEWBIE) - by El Forum - 01-14-2010, 12:08 PM
Nested Query Question (NEWBIE) - by El Forum - 01-14-2010, 03:08 PM
Nested Query Question (NEWBIE) - by El Forum - 01-15-2010, 03:15 AM
Nested Query Question (NEWBIE) - by El Forum - 01-15-2010, 07:44 AM



Theme © iAndrew 2016 - Forum software by © MyBB