Difference between #4 and #5 of
Code style

Revision #5 has been created by g3ck0 on Nov 9, 2010, 4:58:28 PM with the memo:

Highlighted the DON'Ts, added "encapsulated in methods" in Controller section
« previous (#4)


Title unchanged

Code style

Category unchanged


Yii version unchanged

Tags unchanged


Content changed

### Controller

The controller should contain code for collecting user input, retrieving models from the database, and rendering views.

In a controller there should
**never** be: - HTML code: HTML should be in the view - SQL code: If needed, SQL should be in a model, encapsulate in methods.
- Field names: Field names should be in the view
HTML code should only be in views.

Views should
**not** contain:

- User input (e.g. $_GET and $_POST): Input should be collected in models in the controllers, never in views.
Models are used for collecting user inputs, and accessing the database.

In models there should
**not** be:

- User input ($_GET, $_POST): You should write a function that will be called in the controller.
- HTML: HTML should be in a view
29 0
Viewed: 25 031 times
Version: 1.1
Category: Tips
Tags: mvc
Written by: zaccaria
Last updated by: g3ck0
Created on: Nov 9, 2010
Last updated: 11 years ago
Update Article


View all history