CDbCriteria and UNION

Feature request: ability to UNION CDbCriteria objects.

I tried creating a class UnionCriteria which extends CDbCriteria and contains several CDbCriteria objects. I needed to use UnionCriteria with CActiveDataProvider on page with paging and filtering so redefining createFindCommand() and createCountCommand() of CDbCommandBuilder was enough. Had a problem with replacing CDbCommandBuilder with descendant.

My solution works, though I had to edit yii code (when replacing CDbCommandBuilder).

Or would it be better not to union CDbCriteria objects but let CActiveDataProvider have several CDbCriteria objects ?

Just an idea, can’t you use CActiveRecord::findBySql() ?

Surely I can. But when dealing with pagination and sly filters it is right to use CActiveDataProvider.

Okay, then what about using CSqlDataProvider instead? :)

Yeap. I suppose that’s the best thing to do. Thanks.

Though CDbCriteria unioning would be nice anyway.

I agree, it would be! Just trying to help you out in the meantime :)