Possible to create a "virtual" ActiveRecord model?

I have a situation where I need to deal with a grouping of data.

My normal AR models are Course, CourseCategory, Questionnaire, and QuestionnaireSurvey.

I’ve built reports that deal with data from each of those models, but now I have to build a report that represents data accumulated from those tables, i.e. - the aggregate results of QuestionnaireSurvey responses.

Instead of having to build custom queries to deal with the data, I would much rather be able to query the data using model associations, and still have the benefit of AR record fetching as well, for relations.

Is there a Yii method to create a model that represents the aggregation of this data while allowing full AR functionality (aside from create/update records, as this is read-only)?

Why can’t you use basic Relational AR, like QuestionnaireSurvey::model()->with(‘Course’)->findAll() ?

Also, have a look at CActiveDataProvider.

PS. If the query is too complex, I’d prefer to create a DB view.

You can build a view to create a ‘virtual table’ with agreggated data from your tables. And then, create a ActiveRecord to that view.

;)

Interested in doing something similar. In my case, I’ve got about three sub-selects that all bubble up to a yes / no value that needs to be tied to an existing AR model. Did you ever figure anything out on this? I think a view would be overkill …