Home arrow MySQL arrow Abstracting Access to MySQL for an MVC-Based Framework in PHP 5

Abstracting Access to MySQL for an MVC-Based Framework in PHP 5

In this third part of the series, I further enhance the functionality of this sample MVC framework by adding a class to it that takes care of interacting with MySQL in a simple manner. You’ll see the importance of this abstraction class when I show you the definition of the corresponding model, which will aggregate an instance of “MySQL” to handle the data layer very easily.

  1. Abstracting Access to MySQL for an MVC-Based Framework in PHP 5
  2. Listing the partial source files of the framework
  3. Building a basic database abstraction class
  4. Showing the framework’s source files
By: Alejandro Gervasio
Rating: starstarstarstarstar / 6
June 09, 2010

print this article



Despite how intimidating this task may sound to you, building a framework in PHP 5 that follows the structure imposed by the Model-View-Controller design pattern is much easier than you may think.

So, if you’re interested in learning the key concepts that surround this process, either for building your own MVC-based framework or simply for understanding more clearly the underlying logic of existing ones, then start reading right now!

Welcome to the third episode of a series that shows you how to build a simple MVC-based framework in PHP 5. This series walks you through the progressive development of a basic framework with PHP 5 that uses the functionality provided by the MVC design pattern to separate business and application logic from visual presentation.

And now that you’re aware of the goal of this series, it’s time to review the topics that were treated in the last installment. In the last article I left off by adding to the framework a router/dispatcher class. This class was tasked first with parsing all of the users requests, then instantiating when possible the appropriate controller class, and finally calling a method that matches a specific portion of that request.

In many production frameworks, the routing and dispatching processes are performed by separate classes or modules, but for the sake of simplicity the framework that I’m building here will execute those tasks by using a single class.

Having outlined the basic functioning of the router/dispatcher class, it’s time to continue extending the framework’s existing functionality. In this third chapter of the series I’m going to build a basic MySQL abstraction class to interact with a specified database, which will be the default persistent storage mechanism used by the framework.

To learn the full details for how this new class will be developed, click on the link below and read the next few lines!

>>> More MySQL Articles          >>> More By Alejandro Gervasio

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Oracle Unveils MySQL 5.6
- MySQL Vulnerabilities Threaten Databases
- MySQL Cloud Options Expand with Google Cloud...
- MySQL 5.6 Prepped to Handle Demanding Web Use
- ScaleBase Service Virtualizes MySQL Databases
- Oracle Unveils MySQL Conversion Tools
- Akiban Opens Database Software for MySQL Use...
- Oracle Fixes MySQL Bug
- MySQL Databases Vulnerable to Password Hack
- MySQL: Overview of the ALTER TABLE Statement
- MySQL: How to Use the GRANT Statement
- MySQL: Creating, Listing, and Removing Datab...
- MySQL: Create, Show, and Describe Database T...
- MySQL Data and Table Types
- McAfee Releases Audit Plugin for MySQL Users

Developer Shed Affiliates


Dev Shed Tutorial Topics: