Over on phpPatterns.com this morning, there's a new pattern posted dealing with results.
Results come in all shapes and sizes, and this pattern (The Iterator Pattern) can help you with the kind with multiple values - things like arrays, database results, and the contents of a file. It gives you some standard functionality to work with, including fetch, reset, and size functions. Through these functions, you can create an "iterator" class that will allow you to access any number of result types abstractly through your code. All that would be needed is to switch out the class/methods behind the object, and the rest of your code remains the same.
This approach is good, but only if your code is built to handle it. More standardized PHP code is really needed before something like this can be useful to the general public, but with more and more new developers coming "into the fold" all the time, keeping up those standards is becoming harder and harder...




