0% found this document useful (0 votes)
54 views

MVC Architecture Demonstration: Submitted by

This document describes an MVC architecture demonstration project built using CodeIgniter. It includes an introduction to MVC, descriptions of its components (Model, View, Controller), diagrams showing the workflow and relationships between classes, and the source code for the model, controller, and view. The project is a simple database application that allows users to enter and store score data for a match between two teams.

Uploaded by

ishashisp
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views

MVC Architecture Demonstration: Submitted by

This document describes an MVC architecture demonstration project built using CodeIgniter. It includes an introduction to MVC, descriptions of its components (Model, View, Controller), diagrams showing the workflow and relationships between classes, and the source code for the model, controller, and view. The project is a simple database application that allows users to enter and store score data for a match between two teams.

Uploaded by

ishashisp
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

MVC Architecture Demonstration

Submitted by:
Roll no: 126 USN : 2sd10cs090 B division

INDEX
1. MVC Introduction 2. Components of MVC 3. Architectural Diagram of MVC 4. Description of Application 5. Work flow of Application 6. Class Diagram 7. State Diagram 8. Sequence Diagram 9. Source Code

1. MVC Introduction : Model-View-Controller (MVC) is a software architecture / architectural pattern used in software engineering. It Isolates domain logic from user interface. 2. Components of MVC:

Model : It handles data processing and database works part. Model processes events sent by controller. After processing these events then it sends processed data to controller (thus, controller may reprocess it) or directly to view side. View :View prepares an interface to show to the user. Controller or model tells view what to show to the user. Also view handles requests from user and informs controller. Controller : processes every request, prepares other parts of the system like model and view. Then the system determines what to do by controllers commands.

3. MVC Architectural Diagram :

4. Description of Application : Its a simple database application module built by using Codeigniter (a PHP framework), in which view accepts Input from the user passes to the controller and conroller handles input and loads the corresponding model then model process the data stores in to the database.

5. Work Flow of Application :

6. Class diagram:

7. State Diagram :

8. Sequence Diagram:

9. Source Code : Model : score_model.php <?php class Score_model extends CI_Model { var $query = ''; function get_score() { $query = $this->db->get('currentmatch', 1); return $query->result(); } function add_score($score) { $this->db->insert('currentmatch', $score); return; } } controller : score.php <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Score extends CI_Controller { public function index() { $data = array(); $this->load->view('score');

public function add_score()

{ $score = array( 'team1_score' => $this->input->post('team1_score'), 'team2_score' => $this->input->post('team2_score'), 'team1_name' => $this->input->post('team1_name'), 'team2_name' => $this->input->post('team2_name'), ); $this->score_model->add_score($score); $this->index(); } }

View : score.php <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>MVC Demonstration</title> </head> <body> <div id="container"> <h1>Welcome to Smash'13</h1> <?php echo form_open('score/add_score'); ?> <label for="matchno">Team1 Score: </label> <input type="text" name="team1_score"><br/> <label for="matchno">Team2 Score: </label> <input type="text" name="team2_score"><br/> <label for="matchno">Team1 Name: </label> <input type="text" name="team1_name"><br/> <label for="matchno">Team2 Name: </label> <input type="text" name="team2_name"><br/> <input type="submit" Value="submit"> <?php echo form_close(); ?>

</div> </body> <p class="footer">Devloped by <strong>&copy SDMCET Media</strong> </p> </html>

You might also like