hawkenterprises wrote:I think a better question to ask is why are you using MVC if you don't fully understand it. I'm not trying to be harsh I just find that there are waaaay too many people thinking that MVC is going to be the end of solution to there problems when most of the time it's the root of all that is evil.
Nonsense. We all start somewhere. Besides...software design and architecture are moving targets -- they are constantly improving and adapting to their environments.
They are design 'patterns' after all...not design 'solutions'
To answer the OP:
Execution of DB queries can go in one of two places in my experience:
1) Data Access Layer - Table Data Gateway (provides a low-level API to manipulate data store)
2) Model
I have used a data access layer in the past, so that my data stores may change easily. If the DAL provides an API such like:
Code: Select all
createMember($fname, $lname, $age);
The implementation can be anything and the data store can change as well (RDBMS, XML, CSV, Web Services, etc).
The model the manipulates the DAL (TDG) and provides the business logic, such as checking for duplicates, checking format, etc.
Note: DAL is somewhat Mircosoft -centric and not common around PHP or Java communities, but it forms the basis (beginnings) of my own understanding of MVC and software architecture and old habits die hard -- plus it's easier to pronounce than TDG.
Table Data Gateway is Martin Fowler's description of a solution which solves a very similar problem. Although he seems to feel it's simply a API for SQL code, the DAL can provide a wrapper API around any data store.
p.s-As for Rasmus and MVC...
I don't have much of a problem with MVC itself. It's the framework baggage that usually comes along with it that I avoid
It's only baggage if it's not doing anything. A well crafted MVC framework/application should never exceed more than 5% waste in the executing context in terms of SLOC, resources, clock cycles, etc...
I have dealt with this issues zelously in my own framework/application(s) and I can say in confidence I seldomly go above 2%. That is, if request requires 30 files at 4500 lines. There is maybe a single function, about 90-100 lines of code which is never actually executed, but just goes along for the ride.
Cheers
