Prev | Current Page 61 | Next

Emilian Balanescu and Cristian Darie

"Beginning PHP and MySQL E-Commerce: From Novice to Professional, Second Edition"

This may seem to be unnecessary overhead for you right now;
however, there is a substantial future benefit of adhering to this system whenever you need to
change your site??™s functioning or logic.
Figure 2-1 is a simple representation of the way data is passed in an application that
implements the three-tier architecture.
Figure 2-1. Simple representation of the three-tier architecture
A Simple Example Using the Three-Tier Architecture
It??™s easier to understand how data is passed and transformed between tiers if you take a closer
look at a simple example. To make the example even more relevant to our project, let??™s analyze
a situation that will actually happen in TShirtShop. This scenario is typical for three-tier applications.
Like most e-commerce sites, TShirtShop will have a shopping cart, which we will discuss
later in the book. For now, it??™s enough to know that the visitor will add products to the shopping
cart by clicking an Add to Cart button. Figure 2-2 shows how the information flows through
the application when that button is clicked.
CHAPTER 2 ?–  LAYING OUT THE FOUNDATIONS 16
At step 1, the user clicks the Add to Cart button for a specific product. At step 2, the presentation
tier (which contains the button) forwards the request to the business tier, ???Hey, I want this
product added to my shopping cart!??? At step 3, the business tier receives the request, understands
that the user wants a specific product added to the shopping cart, and handles the request by
telling the data tier to update the visitor??™s shopping cart by adding the selected product.


Pages:
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73