[wp-hackers] Active Record / ORM enhancements discussion for WPDB class

Jacob Santos wordpress at santosj.name
Thu Jul 15 19:10:57 UTC 2010


Really, I want to start by apologizing to someone. I had made the argument a
while back when this was brought before that it would be a "Bad Idea(TM)"
based on performance, lines of code additions, amount of testing involved,
and the hate I had for those two patterns.

I was wrong. After using both the Active Record and ORM patterns in several
libraries, I can admit that the person was correct in that using it eases
SQL queries to the point of no nonsense, "Hey, writing SQL queries is fun
again!" Performance and overhead is minimal enough to not even matter.

There are several problems:

1. Currently there is no code and no code generally means any discussion is
just blowing smoke. The reason to bring this up is generally to weigh debate
as to whether this could ever happen in the current state of WordPress
community and core committers.

2. There are a few libraries currently that implement both (keep in mind
that WPDB was also an external library at one time) and have been around for
quite a while. Most if not all are PHP5+ only, but it is only a matter of
time before WordPress changes over to PHP5+. So if this idea does go
forward, the issue will have to be addressed as to whether the current WPDB
class is extended or an existing library is used.

3. Backwards Compatibility. Given that most if not all plugins that have
their own tables or do their own queries will access the WPDB class and will
expect certain methods and behavior, any changes in library will require the
same behavior be available for at least several versions or so.

4. Dissent within core commit community. I'd have to say that if the leads
say no, then no time should be wasted on it. Of course, this doesn't stop
plugins / themes from using existing libraries or rolling one's own based on
WPDB. The problem is that it would affect extensions to WPDB.

Really, the importance of the discussion / debate based on importance is 4
and 2. Discussions based on 1 and 3 should probably be after 4 and 2.

Jacob Santos


More information about the wp-hackers mailing list