PHP
  Home arrow PHP arrow The LIKE Clause and the Active Record Pattern
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

The LIKE Clause and the Active Record Pattern
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 2
    2009-03-24


    Table of Contents:
  • The LIKE Clause and the Active Record Pattern
  • Review: conditional SELECT queries with the active record pattern
  • Working with LIKE clauses
  • The fetchLike() method in action

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    The LIKE Clause and the Active Record Pattern
    ( Page 1 of 4 )

    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.

    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
     

       

    PHP ARTICLES

    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...
    - Method Chaining in PHP 5
    - The Role of Interfaces in Applying the Depen...
    - Dependency Injection: Using a Setter Method ...
    - Using a Model Class with the Dependency Inje...
    - Injecting Objects Using Setter Methods with ...
    - Injecting Objects by Constructor with the De...
    - The Dependency Injection Design Pattern in P...
    - Performing Inferential Statistical Analysis ...
    - Performing Descriptive Statistical Analysis ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    Stay green...Green IT