Dear Techie's,
The model view controller(MVC) pattern is the most used pattern for today’s world web applications. The MVC pattern separates an application in 3 modules: Model, View and Controller
More Details : http://www.htmlgoodies.com/beyond/php/article.php/3912211
This is overview of MVC design pattern. based on MVC structure i have created Model class. that is,
The model view controller(MVC) pattern is the most used pattern for today’s world web applications. The MVC pattern separates an application in 3 modules: Model, View and Controller
- Model : The model is responsible to manage the data. it stores and retrieves entities used by an application, usually from a database, and contains the logic implemented by the application.
- View : The view (presentation) is responsible to display the data provided by the model in a specific format. It has a similar usage with the template modules present in some popular web applications, like wordpress, joomla
- Controller : The controller handles the model and view layers to work together. The controller receives a request from the client, invokes the model to perform the requested operations and sends the data to the View. The view formats the data to be presented to the user, in a web application as an html output.
More Details : http://www.htmlgoodies.com/beyond/php/article.php/3912211
This is overview of MVC design pattern. based on MVC structure i have created Model class. that is,
Class Name : MainModel.class.php
//import a dbconnection class
require_once 'dbConnection.class.php';
//class MainModel
class MainModel {
//variables
var $dbcon;
public $error = '';
//You call a constructor when you create a new instance of the class
//'MainModel' containing the constructor.
//ex : obj = new MainModel(); (PHP 4)
//The "__construct" was introduced in PHP5 and it is the right way to define your, well, constructors
// (in PHP4 you used the name of the class for a constructor). You are not required to define a
//constructor in your class, but if you wish to pass any parameters on object construction then you
//need one. more info : http://php.net/manual/en/language.oop5.decon.php
public function __construct() {
//create '$dbcon' Object
$this->dbcon = new dbConnection();
}
//database connection method
public function ConnectDB() {
//$this refers to the instance of the class
//when we use '$this->dbcon' it refers object of same class. and using this object we should call the connect method.
$con = $this->dbcon->connect();
if ($con) {
return true;
}
}
//database disconnect method
function DisconnectDB($dbcloseval) {
if ($this->dbcon->disconnect($dbcloseval) == false) {
return false;
} else {
return true;
}
}
}?>







0 comments:
Post a Comment