Page 1 of 1

ActiveRecord

Posted: Wed Jan 11, 2006 4:26 pm
by Maugrim_The_Reaper
In the past few days I've been trying to figure out the latest hype over this ActiveRecord ORM approach (I blame it on Ruby on Rails!). It seems everyone and their dog is adding it to PHP Frameworks - even Zend apparently (though their use case seems to contravene the workings of PHP). What's confusing as hell however is the focus on metaprogramming - why do so many of these have "SHOW COLUMNS" sql calls (a mysql example) that must have occured to someone as a bit iffy performance wise? Is it necessary to automagically generate ActiveRecord subclasses at runtime? And why is so much functionality bundled into the parent class - and copied to evey inheriting object, rather than some abstracting all this repitition out to a referenced third object (saving on the memory it eats - which is important for many of us on shared hosts).

The more I look, the more I dislike, or itch to change. I even got confused after figuring out too late its not even the ActiveRecord design pattern Fowler describes!

Wondering if anyone here is using ActiveRecord (not the Fowler pattern - the Ruby On Rails misnamed one), and whether anyone has been convinced of its advantages (if any) over more traditional ORM methods...

Posted: Wed Jan 11, 2006 4:30 pm
by Ambush Commander
Is it metadata mapping?

Posted: Thu Jan 12, 2006 2:45 am
by Maugrim_The_Reaper
Basically... The versions I keep finding are running a SHOW COLUMNS query (if MySQL), collecting table and field information, saving these to object properties, and using as a basis for ActiveRecord methods (the save(), get() etc when generating SQL). I would have thought straight code generation of all these classes make a lot more sense. But then domain objects are extending the ActiveRecord - so it needs to customise itself for every instantiation.

That can add up to a lot of SQL queries to collect metainformation depending on the number of domain objects for data representation... Doesn't seem worth the performance hit.

Posted: Thu Jan 12, 2006 8:58 am
by timvw
If i'm not mistaken pear DataObjects only generates the actuall classes when you ask for it (run show columns etc...) After that it always uses the cache... I think most implementations are moving towards this approach..