Beyond Activerecord - Where Do I Go?

I’m trying to build an application that goes beyond having relationships that are easily mapped 1:1 between Model and Database. I’ve had a look around the forums and the internet in general and there seems to be a big debate about “The Vietname of Computing Science” and Mappers etc. but I haven’t found the golden bullet, that I’ve admittedly been looking for.

Is there a best practice in Yii for how you organise your database interaction when “standard” AR fails you? I’ve read about behaviours, single table inheritance and overriding the instantiate method. I’ve not had that “aha” moment where I was looking at an obviously good solution to this issue. One option I have considered is using RedbeanPHP but that would be a pretty big step away from Yii.

Do I introduce a data mapper class to convert my PHP classes into entities I can store? What do I do?

If you could point me one direction or another I’ll do my best to go there.

Thanks for your help.

Hi SebK,

I think that Yii ActiveRecord models are pretty powerful, and behaviors are a nice way to add common functionality to them without duplicate code (among other benefits).

What kind of features you need in your application?



Hi leandro,

As soon as my model doesn’t easily map to a single table, I get lost. For example when I have inheritance, i.e. a structure like this (I’m still trying to figure out exactly how I want to break the classes down but this would make sense to me to begin with) (can’t seem to insert the png file, sorry I’m at work…)