Home arrow PHP arrow Creating a Model Class for an MVC-based Framework

Creating a Model Class for an MVC-based Framework

In this ninth part of the series, I add an extensible model class to the framework. This class can be used for running CRUD operations against a selected MySQL database table.

  1. Creating a Model Class for an MVC-based Framework
  2. Review: the View class
  3. Managing the database layer with a basic model class
  4. Deleting database records with a final model class method
By: Alejandro Gervasio
Rating: starstarstarstarstar / 3
June 28, 2010

print this article



Learning how to implement the Model-View-Controller design pattern is one of those things that you, as a PHP programmer, will have to face sooner or later, especially if you want to follow modern web development approaches.

The good news is that the learning process doesnít have to be boring. It's possible to get familiar with the key concepts that surround the application of this popular design pattern during the development of a real-world project.

Thatís exactly what this group of tutorials attempts to achieve; while reading them, you'll arm yourself with the background required to build a simple,  extensible object-oriented framework, which will rely on the structure of the Model-View-Controller design pattern to leverage all of its functionality.

If you've been following the tutorials to this point, you'll see that I've used them to build, step by step, a decent stack of libraries. These comprise the core components of the framework. They include a MySQL driver and a caching class, a basic HTML form helper and a view-handling class.

I left off in the last installment explaining how to build this last component, thus providing the framework with the capability to  parse view files in a very straightforward manner. However, handling views is only one-third of the tasks that an MVC framework must perform. It must also be capable of interacting with the database layer through one or more models.

So, in the lines to come Iím going to develop a model class, which will aggregate an instance of the MySQL driver built previously, to handle MySQL database tables through a unified API.

Ready to learn how to build a class like this? Then start reading right now!

>>> More PHP Articles          >>> More By Alejandro Gervasio

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates


Dev Shed Tutorial Topics: