Welcome Guest, Not a member yet? Register   Sign In
Calling the database from a view file?
#7

[eluser]kgill[/eluser]
You're over-thinking this... Instead of returning the query object from your model, return the data you actually need either as an array or an object. This means you process the result object in your model and then you're free to do what you need to do such as your looping through the results and running a 2nd query to add in the number of comments.

However, the simpler solution would be to select what you want from the start, join the two tables (blog posts & comments) and select the posts + a count of comments grouped by the blog posts in your model.


Messages In This Thread
Calling the database from a view file? - by El Forum - 02-08-2009, 11:42 AM
Calling the database from a view file? - by El Forum - 02-08-2009, 12:04 PM
Calling the database from a view file? - by El Forum - 02-08-2009, 01:18 PM
Calling the database from a view file? - by El Forum - 02-08-2009, 01:54 PM
Calling the database from a view file? - by El Forum - 02-08-2009, 02:16 PM
Calling the database from a view file? - by El Forum - 02-08-2009, 02:49 PM
Calling the database from a view file? - by El Forum - 02-08-2009, 02:54 PM
Calling the database from a view file? - by El Forum - 02-10-2009, 12:36 AM
Calling the database from a view file? - by El Forum - 02-11-2009, 08:12 AM



Theme © iAndrew 2016 - Forum software by © MyBB