[eluser]Dave Stewart[/eluser]
Hi All,
I've some questions about the best way to structure classes in order to be flexible, and true to the MVC pattern, within the way that CI likes to work.
So, here's what I'm doing.
1 - I've a bunch of tables, including users, services, products, invoices, etc.
2 - A user can select any one of a number of report types, each of which will call up a fairly different SQL multiple join, returning different-sized and structured datasets
3 - Next, a table is created (although this could be a graph) and it is handed to the view
4 - Additionally some JavaScript related to the table is handed to the view (to allow such things as sorting etc)
5 - Depending on the report chosen, there may also be other HTML options that will be sent to the view
In summary:
1 - report type
2 - data
3 - view
4 - javascript
5 - further options
So, questions:
- Should I build a single model per report, or a master model with a function per report?
- What should the model contain: only database functionality, or the functionality for the JavaScript and HTML as well, or should this be in a controller?
- or should I just be including the actual javascript and such like in custom views per report?
As you can see, I'm not sure where to put everything in order to retain the MVC spirit.
Cheers,
Dave