Web Development Software
5/14/04
<< 72 Squared Weblog

PHP Eclipse Class Library

There are a lot of database abstractions out there. Which one should you choose? I've tried a bunch, and the one that stands out is a brilliant framework called Eclipse.

Eclipse provides simplicity, extensibility and stability. Best of all it is very fast and light-weight. I have used a lot of different database abstractions. I started out on EzSQL by Justin Vincent. Its a simple library that makes it easy to get your results and check what went wrong.
The main problem with it is that it caches result sets before it returns the data. This is actually a good thing when you are working with smaller result sets that you may need to iterate through several times. Not so good when your result sets start climbing into the hundreds or thousands. Some may say that the solution to this problem is to limit your result set. I have tried this approach, but it really breaks down when you want to try to provide users with paged result sets. This cache approach to database abstraction breaks down completely, causing PHP to run sluggishly or take even minutes to return a page.
An alternative approach is to eliminate the abstraction all together and use the native PHP functions. The problem with this is that PHP does not use a very standardized approach to dealing with databases. An abstraction allows you to switch between database platforms with greater ease (something I do frequently). The best alternative I've found is to use an abstraction the provides a standardized set of methods but remains as "close" to the native functions as possible. No caching. No manipulating the data before it's needed.
ADODB is a fantastic library and it does this job well, especially when you stick to the core classes. However, try reading the source code. It is so bloated! Not much better than the PEAR DB abstraction.
In contrast, Eclipse source code is lean and to the point. Instead of piling on more and more conditionals to try to get the class to handle all sorts of situations that invariably arise when connecting and communicating with databases, Eclipse extends the base methods to provide exactly the result you expect. Reading the source code leaves me with a feeling of awe and admiration. Of course, I immediately started hacking it and extending it. And that's the real beauty of this framework. It is so easy to extend because the logic is so clear in the base classes. If a particular function isn't available, it is easy enough to create the new functionality with a simple interface class. Iterating through the result sets is easy and error free. Paged result sets are easy to manufacture. If you are in the market for a new DB abstraction Library, I suggest you check this one out.
See: http://www.students.cs.uu.nl/people/voostind/eclipse/index.php?page=home