<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Fri, 24 May 2013 21:21:22 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Jeremy Cook's Blog: Implementing IteratorAggregate and Iterator]]></title>
      <guid>http://www.phpdeveloper.org/news/17956</guid>
      <link>http://www.phpdeveloper.org/news/17956</link>
      <description><![CDATA[<p>
In a recent post to his blog <i>Jeremy Cook</i> has gotten back into looking at some of the SPL functionality that comes with PHP. In <a href="http://jeremycook.ca/2012/05/06/implementing-iteratoraggregate-and-iterator/">this new post</a> he looks specifically at the IteratorAggregate and Iterator object types.
</p>
<blockquote>
After a bit of a break I'm finally able to get back to writing about the predefined interfaces in PHP. PHP provides two interfaces that allow you to define how your objects behave in a foreach loop: IteratorAggregate and Iterator. Before taking a look at IteratorAggregate I'll briefly discuss how we can iterate over objects in PHP 'natively' and what it means to be Traversable.
</blockquote>
<p>
He introduces the concepts being being "iteratable" and "traversable". He then shows how to implement the IteratorAggregate (only one method required, "getIterator") and Iterator ("next", "valid", "current" and "key" methods required) in classes of your own. 
</p>
<p>
You can find out more about these two object types (including more sample usage) on their manual pages: <a href="http://us3.php.net/IteratorAggregate">IteratorAggregate</a> & <a href="http://us3.php.net/manual/en/class.iterator.php">Iterator</a>.
</p>]]></description>
      <pubDate>Mon, 14 May 2012 13:04:58 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Till Klampaeckel's Blog: Iterating over a table (with Zend_Db_Table and Zend_Paginator)]]></title>
      <guid>http://www.phpdeveloper.org/news/16984</guid>
      <link>http://www.phpdeveloper.org/news/16984</link>
      <description><![CDATA[<p>
<i>Till Klampaeckel</i> has a new post today looking at a solution for a common need - <a href="http://till.klampaeckel.de/blog/archives/166-Iterating-over-a-table-with-Zend_Db_Table-and-Zend_Paginator.html">paginating through results</a> as pulled from a database. With the help of the Zend_Db_Table and Zend_Paginator components of the <a href="http://framework.zend.com">Zend Framework</a> it's a simple matter of passing the results into the Paginator and asking for a certain page.
</p>
<blockquote>
So frequently, I need to run small data migrations or transformations. Especially on the way to Doctrine, there's a lot to clean-up in a database which has been used and evolved over five years or so.
</blockquote>
<p>
Code snippets are included to define a class for the table, extending Zend_Db_Table_Abstract, and a new Zend_Paginator_Adapter_DbTableSelect object to create the paginated results. After that, it's as simple as setting the number of items per page and asking for a certain page. There's even a quick bit about being able to edit the rows inside the paginator directly (they're just Zend_Db_Table_Row records).
</p>]]></description>
      <pubDate>Wed, 12 Oct 2011 11:01:44 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Christian Schaefer's Blog: Simply iterate over XML with plain PHP using little memory and CPU]]></title>
      <guid>http://www.phpdeveloper.org/news/16023</guid>
      <link>http://www.phpdeveloper.org/news/16023</link>
      <description><![CDATA[<p>
In <a href="http://test.ical.ly/2011/03/08/simply-iterate-over-xml-with-plain-php-using-little-memory-and-cpu/">a new post</a> to his Test.ical.ly blog <i>Christian Schaefer</i> shows you how to iterate over XML in a more efficient way with the help of the <a href="http://php.net/xmlreader">XMLReader</a> and Iterator features that come with PHP.
</p>
<blockquote>
One of the things I have been working on lately was a simple XML parser. It's a simple XML structure in my case though it could be more complex without much change. My solution was a quite powerful yet simple combination of XMLReader and the Iterator interface.
</blockquote>
<p>
He includes a sample XML document similar to the one he was working with and shows how XMLReader can handle it, keeping only the currently needed information in memory at one time. His sample class (CustomXml) loads the file and defines all of the iterator methods to work with the data like "next", "prev" and "rewind".
</p>]]></description>
      <pubDate>Thu, 10 Mar 2011 08:11:31 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Matthew Weier O'Phinney's Blog: Taming SplPriorityQueue]]></title>
      <guid>http://www.phpdeveloper.org/news/15760</guid>
      <link>http://www.phpdeveloper.org/news/15760</link>
      <description><![CDATA[<p>
<i>Matthew Weier O'Phinney</i> has <a href="http://weierophinney.net/matthew/archives/253-Taming-SplPriorityQueue.html">a new post</a> to his blog today looking at one of the tools the <a href="http://php.net/spl">Standard PHP Library (SPL)</a> has to offer developers - the SplPriorityQueue (PHP 5.3+)
</p>
<blockquote>
<a href="http://php.net/SplPriorityQueue">SplPriorityQueue</a> is a fantastic new feature of PHP 5.3. However, in trying to utilize it in a few projects recently, I've run into some behavior that's (a) non-intuitive, and (b) in some cases at least, undesired. In this post, I'll present my solutions.
</blockquote>
<p>
He talks about the "first in, first out" nature of queues and how it differs from a stack (including links to some of the other SPL offerings for both). He then moves into the problems he was seeing - that iteration removes values from the heap and the unexpected order of equal values in the queue. To solve the first problem, he creates an "outer iterator" that creates an "innerQueue" that's protected. The solution for the second issue - the random queue order - is a simple one: priority indexes aren't required to be integers. Strings can be substituted to help make things a bit more unique.
</p>]]></description>
      <pubDate>Tue, 18 Jan 2011 12:43:54 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Matthew Turland's Blog: A Few Kinks in FilterIterator]]></title>
      <guid>http://www.phpdeveloper.org/news/14963</guid>
      <link>http://www.phpdeveloper.org/news/14963</link>
      <description><![CDATA[<p>
In <a href="http://matthewturland.com/2010/08/15/a-few-kinks-in-filteriterator/">this quick post</a> to his blog <i>Matthew Turland</i> shares a "kink" he found in using the <a href="http://php.net/filteriterator">FilterIteractor</a> SPL iterator when working with <a href="http://phergie.org/2010/08/08/known-issue-in-phergie-2-0-3/">the Phergie project</a>'s code.
</p>
<blockquote>
Once I discovered the <a href="http://en.wikipedia.org/wiki/Segmentation_fault">segfault</a> [from the FilterIterator code], I had to come up with a short code sample exposing the bug in order to report it. 
</blockquote>
<p>
He talks about <a href="http://bugs.php.net/bug.php?id=52559">the bug</a> that led him to the segfault and <a href="http://bugs.php.net/bug.php?id=52560">a second bug</a> that was a side effect of the first causing the first element to be skipped during iteration.
</p>]]></description>
      <pubDate>Mon, 16 Aug 2010 10:18:40 -0500</pubDate>
    </item>
  </channel>
</rss>
