PHP
  Home arrow PHP arrow Page 3 - Using Directory Iterators and MySQL wi...
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

Using Directory Iterators and MySQL with Adapter Objects with PHP
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 5
    2006-12-13

    Table of Contents:
  • Using Directory Iterators and MySQL with Adapter Objects with PHP
  • Working with directory iterators and adapters together
  • Putting the adapter class to work
  • Adapting MySQL result sets

  • 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


    Using Directory Iterators and MySQL with Adapter Objects with PHP - Putting the adapter class to work


    (Page 3 of 4 )

    Naturally, I know that you want to see how the adapter class that I defined in the previous section works, therefore I prepared a concrete example that demonstrates clearly the functionality of this class.

    In this case, and assuming there's a sample "default_path" directory that contains two files named "file1.txt" and "file2.txt," here's the corresponding code sample:

    try{     $dirIteratorAdapter=new DirectoryIteratorAdapter(new
    DirectoryIterator('default_path/'));     echo $dirIteratorAdapter->getDetailedInfo(); } catch(Exception $e){     echo $e->getMessage();     exit(); } /* displays the following: -------------------------------------------------------------------------- Last modification timestamp of current directory entry is : 1155050050 Path of current directory entry is : default_path Type of current directory entry is : dir Full path of current directory entry is :default_path/. Current directory entry is readable -------------------------------------------------------------------------- Last modification timestamp of current directory entry is : 1155061462 Path of current directory entry is : default_path Type of current directory entry is : dir Full path of current directory entry is :default_path/.. Current directory entry is readable -------------------------------------------------------------------------- Last modification timestamp of current directory entry is : 1149698631 Path of current directory entry is : default_path Type of current directory entry is : file Full path of current directory entry is :default_path/file1.txt Current directory entry is readable -------------------------------------------------------------------------- Last modification timestamp of current directory entry is : 1149698651 Path of current directory entry is : default_path Type of current directory entry is : file Full path of current directory entry is :default_path/file2.txt Current directory entry is readable */

    As you can see, the prior example shows how the original "DirectoryIterator" class can be expanded without using inheritance. Also, with reference to the script listed above, you'll realize that it iterates over each directory entry and displays some useful information, such as the path of each element, type, timestamp, and so forth.

    So far, with the example you saw before, I think you should be equipped with a fairly decent background on how to apply the adapter pattern with PHP 5. Nevertheless, I'd like to finish this series by teaching you another case where this pattern can be applied with minor hassles: creating an adapter that expands the capacity of a MySQL result set processing class.

    Want to find out how this adapter class will be created? Jump into the following section and keep reading.

    More PHP Articles
    More By Alejandro Gervasio


       · In this final tutorial of the series, you'll learn how to use the adapter pattern in...
     

       

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





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