SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Always learning viveknarula's Avatar
    Join Date
    Mar 2006
    0 Post(s)
    0 Thread(s)

    Question Models vs Controller ?

    Can anyone tell me in an MVC framework

    what Models should have?
    what controller should have?

    For example :- User defined functions should be in the Models or in the Controller ?


    SQL queries should be in the models or controllers?

    and many things that creates confusion between models and controllers.

    Pls advice

  2. #2
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Copenhagen, Denmark
    0 Post(s)
    0 Thread(s)
    It's "the model", in singular. The model is a collective for the code, which models the real world, hence the name. Model components is also sometimes called business logic.
    Model code is passive; It doesn't read input, and it doesn't produce output. The only way to interact with model components, is through other code (presentation layer code). If your application stores data in a database, then the code, which interacts with the database would belong to the model domain. This means, that you must write libraries, which can talk to the database. These libraries should then be used by the presentation layer of your application (Eg. the code, which actually receives input, and generates output).

    MVC is a three-tier architecture. It has the same properties as a two-tier architecture, but further refines this. Before you can understand MVC, you will therefore need to understand a basic two-tier architecture. For a lot of applications, a two-tier is sophisticated enough -- you often don't need the extra refinement of a three-tier (MVC).


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts