Home arrow PHP arrow Updating and Deleting Database Records with the Active Record Pattern

Updating and Deleting Database Records with the Active Record Pattern

Regardless of its rather intimidating name, the active record pattern is actually quite simple to implement with PHP when developing database-driven applications. Indeed, this pattern permits you to achieve a high level of abstraction when performing typical operations, such as insertions, updates and deletions of records, since all of these tasks are handled transparently by data mappers objects or a data access class.

TABLE OF CONTENTS:
  1. Updating and Deleting Database Records with the Active Record Pattern
  2. Review: fetching and inserting database rows with the active record pattern
  3. Updating database rows with the active record pattern
  4. Deleting database rows with the active record approach
By: Alejandro Gervasio
Rating: starstarstarstarstar / 3
March 10, 2009

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Introduction

Therefore, if you're interested in learning how to implement this useful pattern within a MySQL abstraction class, then this series of articles might be what you really need. In it you'll find numerous examples that will help you to master this topic by mean of a hands-on approach, and best of all, with minor hassles.

Of course, if you already read the previous article, then you're familiar with utilizing the active record pattern in conjunction with a MySQL abstraction class. In that particular tutorial I discussed this topic extensively, and hopefully this experience has been instructive for you.

In simple terms, this MySQL-handling class was provided with the ability to fetch and insert database rows without the need to code explicitly any SQL statements. This can be fairly helpful in achieving a neat level of SQL abstraction.

However, this educational journey has just started. It's possible to apply this pattern to update and delete rows from a selected MySQL table. Therefore, in the next few lines I will demonstrate how to perform updates and deletions through the sample MySQL class developed in the previous tutorial.

Now, it's time to learn how to use the active record pattern for performing database updates and deletions in a few simple steps. Let's jump in!



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

blog comments powered by Disqus
   

PHP ARTICLES

- 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...
- PHP: Building Concrete Validators
- Sanitizing Input with PHP
- Executing Shell Commands with PHP
- Handling File Data with PHP
- File Security and Resources with PHP
- ArrayObject PHP Class Examples
- ArrayObject PHP Class: An Introduction
- Getting File System Data with PHP
- PHP Tools for Working with the File and Oper...
- Working with the File and Operating System w...
- PHP Proxy Patterns: Completing a Blog


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 11 - Follow our Sitemap

Dev Shed Tutorial Topics: