For the project I mentioned in my last post I’ve also been using a fantastic class called ezSQL that really makes a lot of things an absolute piece of cake. I don’t remember exactly how I came across this class, perhaps via Simon, but at the time I wasn’t doing anything I could use it for and so I just bookmarked it and made a mental note to check it out later. After not much more than a night of using it the syntax is already very intuitive to me and I look at the documentation hardly at all; the class itself is so logically done that a quick glance at the code is just as helpful as the documentation. Of course there is some room for improvement, for example it would be nice if the errors and such were valid XHTML, but I’ll survive.
My only problem with ezSQL is related to efficiency – PHP’s mysql functions allow you to iterate through potentially huge queries by only holding the current row in memory at any one time. ezSQL reads back the whole result set in to a PHP data structure, which works fine for small queries but could result in a real problem if you’re working with a query that returns thousands of rows.
At the end of the day though, web applications rarely have to deal with more than a hundred or so results (and careful use of the limit argument can keep this well in check) so it’s unlikely to cause any problems in practical terms.