PHP
  Home arrow PHP arrow Working with MySQL Result Sets and the...
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Mobile Linux 
App Generation ROI 
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

Working with MySQL Result Sets and the Decorator Pattern in PHP
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 12
    2006-09-05

    Table of Contents:
  • Working with MySQL Result Sets and the Decorator Pattern in PHP
  • Handling MySQL result sets
  • Retrieving MySQL result sets without changing the original class
  • Defining multiple decorator classes

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb 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


    Working with MySQL Result Sets and the Decorator Pattern in PHP


    (Page 1 of 4 )

    If you’re one of those avid PHP developers who wants to learn how to apply the decorator design pattern within your Web applications, then this group of articles might be quite appealing to you. Welcome to the second part of the series “Using the Decorator pattern with PHP.” Comprised of two parts, this series walks you through the core concepts of using this pattern in PHP, and shows you its practical edge with numerous hands-on examples.

    Introduction

    For those readers that just found this article after doing some research on the Web, let me tell you that in the previous tutorial, I explained the foundations of the decorator pattern in PHP, and developed an easy-going example to show how it works. Basically, this pattern will allow you to add more functionality to an existing class, without having to change its original structure.

    As I mentioned right at the beginning of this series, this result also might be achieved by using inheritance and creating some subclasses from a base class. However, depending on the context where an application will be developed, there are times when it’s preferable to work with objects of different types, instead of using child objects that belong to the same family.

    Whatever reasons you have for using objects of different types, the fact is that creating decorator objects in PHP is admittedly easy. In this second article, I’ll take advantage of this handy feature by demonstrating how the decorator pattern can be used in a real situation that you probably tackle very often: processing MySQL result sets.

    Definitely, the pattern in question can be used for generating different types of outputs (or views) based on a returned result set, by using a few decorator classes that I’ll define in the course of this tutorial. Hopefully, when you finish reading these lines, you should have a clear idea of how to include decorator classes in your object-based PHP applications.

    Are you ready to learn more about the decorator pattern? Okay, let’s get started!

    More PHP Articles
    More By Alejandro Gervasio


       · In this final part of the series you'll learn how to apply the decorator pattern in...
       · Why do you pass the "resultdecorator" object as a parameter to it's child objects...
       · Thank you for commenting on this article. With regards to your question, the reason...
       · I'm not quite following your reasoning. If you pass the resultdecorator to the...
       · Yeap, you're correct. StringResultDecorator is a child of ResultDecorator, so it...
       · I'm trying out a tabledecorator class and in it I need to know the number of...
       · Thank you for the comments on my PHP article. With regard to your question, you can...
     

       

    PHP ARTICLES

    - Using Aliases and the Autoload Function with...
    - Authentication Scripts for a User Management...
    - Utilizing the Use Keyword for Namespaces in ...
    - Building a User Management Application
    - Working With Different Namespaces in PHP 5
    - User Management Explained: Overview
    - Using Namespaces in PHP 5
    - Building a Modular Exception Class in PHP 5
    - Database and Password Security for Web Appli...
    - Handling MySQL Data Set Failures in PHP 5
    - Building Site Registration for Web Applicati...
    - Intercepting Customized Exceptions in PHP 5
    - Sub Classing Exceptions in PHP 5
    - Building a Content Management System with Co...
    - Filters and Login Systems for Web Applicatio...

     
    Application Delivery: Everything You Wanted to Know, but Didn`t Know You Needed to Ask
    A comprehensive guide to examining the topics of Wide-area Data Services and app....

     
    Best Practices: Safe and Secure Hardware Asset Recovery
    Companies increasingly must meet EPA and local requirements for the disposal of ....

     
    Managing SSL Security in Multi-Server Environments
    Read this white paper to learn how to simplify management of your organization's....

     
    Open Source Security Myths
    Open Source Software (OSS) is computer software whose source code is available t....

     
    Power and Cooling Capacity Management for Data Centers
    This paper describes the principles for achieving power and cooling capacity man....

     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
    Stay green...Green IT