Welcome Guest, Not a member yet? Register   Sign In
Returning one data array from multiple MySQL queries
#1

[eluser]Funky Larma[/eluser]
After watching most of the CodeIgniter posts over at NetTuts I decided to give it a go and try to create a project management application.
So far I've got two controllers; Projects and Tasks. Each have a model that retrieves data from a MySQL database and matching views to display the results.

The Project model has a primary key/ID column and then all the details including a status enum. The Tasks model also has a primary key/ID but also a project ID column that references the project ID.

From my Projects controller I get all the projects with a status of 'In Progress' and collect in a array. Normally I pass this array through to the view and use a foreach loop to display each Project on a page.
What I'm stuck on now is how to display a count of all tasks under a Project.

I can't seem to get it straight in my head how best to approach this and get it working.
Is it better practice to create a function in the model that will return the task count with the project details to the controller? Or should I loop through the project details in the controller and try to obtain the task count this way?

Any help or ideas greatly received!


Messages In This Thread
Returning one data array from multiple MySQL queries - by El Forum - 06-16-2010, 07:07 AM
Returning one data array from multiple MySQL queries - by El Forum - 06-16-2010, 08:22 PM
Returning one data array from multiple MySQL queries - by El Forum - 06-16-2010, 10:12 PM
Returning one data array from multiple MySQL queries - by El Forum - 06-16-2010, 10:25 PM
Returning one data array from multiple MySQL queries - by El Forum - 06-17-2010, 01:32 AM
Returning one data array from multiple MySQL queries - by El Forum - 06-18-2010, 01:52 PM
Returning one data array from multiple MySQL queries - by El Forum - 06-18-2010, 03:30 PM
Returning one data array from multiple MySQL queries - by El Forum - 06-19-2010, 02:01 AM
Returning one data array from multiple MySQL queries - by El Forum - 06-19-2010, 10:34 AM



Theme © iAndrew 2016 - Forum software by © MyBB