A simple PHP implementation of 3-tier architecture OOP application.
3-tier architecture is an implementation of Layer Architecture. The general idea behind this architecture is to separate code logic. The following layers are used most commonly in a 3-tier architecture.
- Presentation Layer
- Business Logic Layer
- Data Access Layer
Layers only communicates with adjacent layer. For example, presentation layer communicates to business logic layer and business logic layer communicates with both layers presentation and data access. But Data access layer can not directly communicate with presentation layer.
You need a PHP-MySql server installation to run the application. Only thing, you need to change is database configuration. Follow the instruction below.
- Open the file
Application/DatabaseConnection.php
in any text editor. - In the constructor method, change the values for
$this->dbUser
,$this->dbPassword
,$this->dbName
,$this->dbHost
There is only one table is used for the application. Create the table using the following SQL code.
CREATE TABLE `student` (
`Id` int(11) NOT NULL auto_increment,
`Roll` varchar(50) default NULL,
`Name` varchar(255) default NULL,
`Email` varchar(255) default NULL,
`DateOfBirth` datetime default NULL,
PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Alternatively, you can also run the SQL script file named stdinfo.sql
under the __db
directory.
- ezSQL v2.03: This library gives very nice interface to interact with MySql database.
- Twitter Bootstrap v3.3.5: Very popular frontend framework.
- jQuery v1.11.3 Most popular Javascript framework.
Note 1: This application can be used for educational purpose.
Note 2: To avoid complexity, validation is kept to a minimum level and security check for
SQL Injection is not implemented.