Welcome Guest, Not a member yet? Register   Sign In
Add subquery to main query result instead of running lots of foreachs
#1

[eluser]gr0uch0mars[/eluser]
This is what I HAVE:
I want to show a Disc, with its Songs, and each Version of the songs: Disc > Song > Versions
So far, I have a songs query on my controller that gets all Songs of a Disc. That's OK.
Then I pass it to a view and there I do:
Code:
foreach($songs_query->result() as $song_row) { "search Versions of this song" }
I'm worried about performance, as could be lots of queries to run on each song (12 songs/disc, 4 takes/song = 12*4 queries to see version info)

My QUESTION is this:
Could I alter the songs_query like altering an array to do a single (or at least less) query?

I don't know much about handling this, so any help would be appreciated! Thanks


Messages In This Thread
Add subquery to main query result instead of running lots of foreachs - by El Forum - 08-20-2010, 04:33 AM



Theme © iAndrew 2016 - Forum software by © MyBB