Home arrow PHP arrow The LIKE Clause and the Active Record Pattern

The LIKE Clause and the Active Record Pattern

In most cases, the implementation of the active record pattern in PHP (and other programming languages too) is carried out through a few data mapper objects, which are used to perform CRUD operations on a group of targeted database tables. This seven-part article series describes the advantages of using the active record pattern in a variety of situations, and shows you how to do it.

TABLE OF CONTENTS:
  1. The LIKE Clause and the Active Record Pattern
  2. Review: conditional SELECT queries with the active record pattern
  3. Working with LIKE clauses
  4. The fetchLike() method in action
By: Alejandro Gervasio
Rating: starstarstarstarstar / 2
March 24, 2009

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Introduction

While an approach like the one described above permits to reach a high level of SQL abstraction when accessing databases, the truth is that itís also possible to apply the active record approach by means of a single database class, which encapsulates within its API all the logic required for executing CRUD tasks.

Logically, when using this methodology, programmers wonít need to code  any SQL statements directly, since the class will dynamically construct the SQL queries required for performing records insertions, updates, deletions and so forth.

In this group of articles, youíll be provided with an approachable guide to building a database abstraction class like the one mentioned above, which will let you easily perform the most common database-related operations without having to write a single portion of SQL code.

At this point, you possibly recall that in the preceding tutorial I explained how to build a simple MySQL abstraction class, which could run conditional SELECT statements by utilizing a slightly different version of the active record pattern. Essentially, this class was capable not only of dynamically arming SELECT queries, but working with WHERE clauses, which made running conditional SQL commands a no-brainer process.

However, in its current incarnation, this class's functionality is limited, regardless of its decent level of SQL abstraction. Therefore, in this fourth part of the series Iím going to enhance it by making it capable of working with LIKE clauses in a straightforward way.

Now itís time to get rid of the preliminaries and continue extending the functionality of the MySQL-accessing class developed in the previous article. Letís get going!



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