Home arrow PHP arrow Coding Examples of the Iterator, Countable and ArrayAccess SPL Interfaces in PHP 5

Coding Examples of the Iterator, Countable and ArrayAccess SPL Interfaces in PHP 5

Welcome to the final installment of a series that provides an overview of the Iterator, Countable and ArrayAccess SPL interfaces in PHP 5. Made up of six parts, this series teaches you how to build a fully-working MySQL abstraction class that takes advantage of the methods inherited from these native interfaces to manipulate database record sets easily by using an array syntax.

TABLE OF CONTENTS:
  1. Coding Examples of the Iterator, Countable and ArrayAccess SPL Interfaces in PHP 5
  2. Review: the MySQLiWrapper and MySQLi_ResultWrapper classes
  3. Putting the MySQLi_ResultWrapper class to work
  4. Final script: counting rows in a result set and accessing specified records
By: Alejandro Gervasio
Rating: starstarstarstarstar / 3
April 19, 2010

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

In the articles that preceded this one I demonstrated in a step-by-step fashion how to develop such a MySQL handling class. It effectively defined all of the methods required by the aforementioned interfaces. In doing so, the class now is not only capable of traversing data sets by way of a plain “foreach” construct, but it allows you to count and access rows in those sets as if they were array elements.

Of course, while describing the functionality of this sample class is fine, bragging about it is only the half of the story. It's necessary to show a few examples of how to use the class in a useful way. Therefore, in this last part of the series I’m going to code for you a few basic scripts that will show the actual functionality of this implementing class.

Does my proposal sound good to you? Then start reading now!



 
 
>>> More PHP Articles          >>> More By Alejandro Gervasio
 

blog comments powered by Disqus
   

PHP ARTICLES

- 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...
- PHP: Building Concrete Validators
- Sanitizing Input with PHP
- Executing Shell Commands with PHP
- Handling File Data with PHP
- File Security and Resources with PHP
- ArrayObject PHP Class Examples
- ArrayObject PHP Class: An Introduction
- Getting File System Data with PHP
- PHP Tools for Working with the File and Oper...
- Working with the File and Operating System w...
- PHP Proxy Patterns: Completing a Blog


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 2 - Follow our Sitemap

Dev Shed Tutorial Topics: