Jump to content

Understanding MVC Sorting System


Glese

Recommended Posts

I want to start a new project, before I do so I would like to understand the MVC sorting system better, I do call it a sorting system because I mainly want to use it to sort my php files, I hope this is not the wrong approach.(?)

 

I am simply asking to get a clarification, the way I understood MVC is, that you do put all your "business logic" into Model, for example:

 

form_script.php

 

While you do put your "input logic" into Controller, for example:

 

form_form.php

 

And you do put your "UI logic" into View, for example:

 

article_about_my_travel.php

 

 

 

Is this the right way to understand MVC, and after all the right way to use it with PHP ?

Link to comment
Share on other sites

No.

 

You have three layers:

1)  Data access and application layer.  This is a series of classes which represent your database, performs standard data manipulation tasks, loads, saves, edits, queries, lists, sorts, etc.  Complex operations like creating a new account or placing a new order should also be located here.  This layer is organized around your DATA, not your application.

2)  Business logic layer.  Organizing the website should go here.  A controller controls actions for a specific section or subsection of your website.  Permissions, navigation, and data preparation are done at this layer.

3)  Display/template layer.  The business layer's controllers assign data to the display layer's templates and then the templates simply display the data.  The templates can also have javascript functionality (this is the only location where javascript is acceptable) but they do not perform any tasks in PHP heavier than a basic foreach loop and some If statements.  No functions, no sorting, no algorithms of any kind.

 

 

Link to comment
Share on other sites

I am trying to wrap my head around it, keep in mind I am not the most complex thinker. I just started a new project and tried to use the MVC model and I see it did not do it quite right, so I still can modify it.

 

 

In layman's speech,

 

Model is the area where the scripts and the SQL statements, which means the database accesses or transfer goes to.

 

While controller has also all the static pages and the navigation bar, the links, and also the input forms et cetera, right? Just to state it in layman's speech.

 

While view contains the design aspect, jquery and similar. No functions, no sorting.

 

 

And the purpose of all of these is, I can let others work on this project, by giving them the files they really need and not more. A designer may need the controller level and not necessarily the model level with all the SQL statements, he also may need the view level for the jquery effects.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.