Home arrow PHP arrow The mysqli Extension and the Active Record Pattern

The mysqli Extension and the Active Record Pattern

The active record pattern allows you to access records in a database by means of a unified interface, generally composed of a few data mapper objects. However, as with other popular design patterns, there are several methodologies for implementing it within an object-oriented application, all of which can be used to obtain similar results. In this group of articles, I demonstrate how to progressively build a MySQL abstraction class that uses the active record approach for performing CRUD operations (Create, Retrieve, Update, Delete) on the records of a selected database table.

TABLE OF CONTENTS:
  1. The mysqli Extension and the Active Record Pattern
  2. Getting started using the mysqli PHP extension
  3. Finish updating the MySQL class
  4. The sample MySQL class in action
By: Alejandro Gervasio
Rating: starstarstarstarstar / 4
April 14, 2009

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Introduction

Naturally, if you've read the six preceding articles (this is the seventh and concluding part) then by now you're pretty familiar with creating a class like this. In those articles I explained how to develop a sample MySQL-accessing class that was capable of inserting, updating and deleting records, as well as performing conditional SELECT statements against a specified MySQL table.

In this case, the class accomplished all of these database tasks by way of a slightly modified version of the active record pattern, since no mapper objects were used here. Instead, it implemented a few straightforward methods for executing dynamic queries through a highly-simplified API.

We're not quite finished with this quick overview on accessing MySQL tables with the active record pattern yet, because there’s one step that remains undone. What is it? Well, as you’ll surely recall, I built this class by using the old MySQL library included with the PHP distribution, which is good and efficient.

But it’s worth making the effort to see how this sample class can be rewritten by using the newer, revamped “mysqli” extension. Thus, this last episode will be dedicated exclusively to doing this, so you can have at your disposal an enhanced versions of the class.

Are you ready to tackle this final chapter of the series? Then go ahead and start reading now!



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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- 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: