Is it possible for CSqlDataProvider to yield CActiveRecord instances

Is it possible for CSqlDataProvider to yield CActiveRecord instances just like CActiveDataProvider?

So you can use CSqlDataProvider like you would CActiveDataProvider?

And most important, use relations, with with().

The basic idea is: If you want to use ActiveRecords use CActiveDataProvider. If you want to use a custom SQL statement, use CSqlDataProvider. As ‘with’ is an option of relational ActiveRecord, you can’t use it with the latter. How should that work, if you use custom SQL?

Yes, it doesn’t make much sense, but I was trying to include an Union inside the query, and didn’t know how to do it since a CDbCriteria doesn’t have a union clause. But I’m not sure Unions are standard SQL and that could be why CDbCriteria doesn’t include it.

Anyway, I solved the problem with a Where Exists.