Glese Posted November 27, 2011 Share Posted November 27, 2011 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 ? Quote Link to comment https://forums.phpfreaks.com/topic/251912-understanding-mvc-sorting-system/ Share on other sites More sharing options...
ManiacDan Posted November 27, 2011 Share Posted November 27, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/251912-understanding-mvc-sorting-system/#findComment-1291670 Share on other sites More sharing options...
Glese Posted November 28, 2011 Author Share Posted November 28, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/251912-understanding-mvc-sorting-system/#findComment-1291737 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.