tags:

views:

246

answers:

4
+1  Q: 

ActiveRecord

Does anyone have any recommendations for implementations of ActiveRecord in PHP? I've been using CBL ActiveRecord, but I was wondering if there were any viable alternatives.

+1  A: 

Depends! ;)

For example there is ADODB's Active Record implementation, then there is Zend_Db_DataTable and Doctrine. Those are the ones I know of, I am sure there are more implementations.

Out of those three I'd recommend Doctrine. Last time I checked Adodb carried a lot of extra weight for PHP4 and Zend_Db_* is generally not known to be the best in terms of completeness and performance (most likely due to its young age).

Doctrine aside from Active Table and the general database abstraction thing (aka DBAL) has so many things (e.g. migrations) which make it worth checking out, so if you haven't set your mind on a DBAL yet, you need to check it out.

Till
A: 

Whilst not strictly ActiveRecord, Zend_Db_Table is pretty good.

Dave Marshall
+1  A: 

I found a few examples of other implementations: Luke Baker has one he is calling Active Record in PHP.

Flinn has a post about why it is not possible in PHP because in Ruby everything is an object. With a followup here

I know a few people who have looked at ZF have you tried that?

CakePHP?

Craig
+1  A: 

This is more of a how-to-implement tip, but I started dabbling with creating an ActiveRecord/DataMapper implementation in PHP and quickly ran into many hurdles with array-like access. Eventually I found the SPL extensions to PHP, and particularly ArrayObject and ArrayIterator. These began to make my life a lot easier. Unfortunately I haven't had much time to devote to it, but anyone who tries something like this should check those out.

pbhogan