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.

  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




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