PHP
  Home arrow PHP arrow Page 3 - Using Directory Iterators and MySQL with Adapter Objects with PHP
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? 
Google.com  
PHP

Using Directory Iterators and MySQL with Adapter Objects with PHP
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 6
    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:
      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


    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
     

       

    PHP ARTICLES

    - Implementing Factory Methods in PHP 5
    - Merging a File Split for FTP Upload using PHP
    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - 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





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek