MVC rule



1. mySQL tables will always be lowercase and plural e.g. posts, books
2. Models will always be singular and first letter capital e.g. Post, Book
3. Controllers will always have “Controller” appended to them. e.g. PostController, BookController
4. Views will have plural name followed by action name as the file. e.g. posts/view.php, books/buy.php




For Example :


1. models process


models => post.php

<?php
class Post extends Model {

}

2. controllers 


controllers  = > postscontroller.php



<?php
class PostsController extends Controller {

    function view($id null,$name null,$phone null) {
    
        

       // view / display code here

    }
    
    function viewall() {

      // view all posts
     

    }
    
    function 
add() {
       

        

        
 // add post code here
        

            
    }
    
    function 
delete($id null) {
        

        delete post code here
   
    }

}

3. views = > posts =>


viewall.php
add.php
delete.php


Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s