[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!